fix: Fix BeforeValidator treating 0 as falsy in configuration fields#819
Merged
fix: Fix BeforeValidator treating 0 as falsy in configuration fields#819
Conversation
`lambda val: val or None` coerces `0` and `Decimal(0)` to `None`, making it impossible to set `max_paid_dataset_items=0` or `max_total_charge_usd=0`. Use explicit empty-string check instead, consistent with the existing `timeout_at` validator. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #819 +/- ##
==========================================
- Coverage 85.88% 85.85% -0.04%
==========================================
Files 46 46
Lines 2778 2778
==========================================
- Hits 2386 2385 -1
- Misses 392 393 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Pijukatel
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BeforeValidator(lambda val: val or None)onmax_paid_dataset_itemsandmax_total_charge_usdconfiguration fields treated0as falsy, converting it toNone. This meant a legitimate value of0(e.g. a zero charge limit) would be silently discarded.lambda val: val if val != '' else Nonewhich only converts empty strings (from unset env vars) toNone, preserving0as a valid value.Test plan
max_paid_dataset_items=0is preserved (not converted toNone)max_total_charge_usd=0is preserved (not converted toNone)max_paid_dataset_itemsbecomesNonemax_total_charge_usdbecomesNone🤖 Generated with Claude Code