fix: validate settings that crash at runtime instead of load time - #51
Open
rcbevans wants to merge 2 commits into
Open
fix: validate settings that crash at runtime instead of load time#51rcbevans wants to merge 2 commits into
rcbevans wants to merge 2 commits into
Conversation
Add validators for nine WorkerSettings fields that previously accepted invalid values silently: - log_level: must be DEBUG/INFO/WARNING/ERROR/CRITICAL (case-insensitive) - sso_backend: must be none/oidc/saml (case-insensitive) - poll_interval: ge=0.1 (negative values crash asyncio.sleep) - notify_health_check_interval: ge=0.1 - notify_reconnect_backoff_initial: ge=0.01 - prune_schedule_utc: HH:MM format with range checks - archive_expiry_schedule_utc: same HH:MM validation - prune_cron_expr: validated via croniter.is_valid() - archive_expiry_cron_expr: same cron validation Each follows the existing validator/constraint patterns in settings.py. All existing valid values continue to load unchanged.
The ge=0.1 floor broke tests that use sub-100ms intervals for speed (health_check_interval=0.001, poll_interval=0.05). gt=0 still prevents the negative values that crash asyncio.sleep while allowing any positive value for test acceleration.
rcbevans
force-pushed
the
fix/settings-validation
branch
from
July 30, 2026 04:54
bbb9560 to
f4a1bf2
Compare
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
Nine
WorkerSettingsfields accepted values that passed load-time validation but crashed at runtime. Each now fails fast at settings load with a clear error message.Fields fixed
log_level{DEBUG, INFO, WARNING, ERROR, CRITICAL}(case-insensitive, normalized to uppercase)sso_backend{none, oidc, saml}(case-insensitive, normalized to lowercase)poll_intervalasyncio.sleepge=0.1notify_health_check_intervalge=0.1notify_reconnect_backoff_initialge=0.01prune_schedule_utcarchive_expiry_schedule_utc_hh_mm_validator(parameterized viactx.field_name)prune_cron_exprcroniter.is_valid()in a validator hook (skips None/empty default)archive_expiry_cron_expr_cron_expr_validatorImplementation
Follows existing patterns in
settings.py:_log_level_validator,_sso_backend_validator,_hh_mm_validator,_cron_expr_validator) match the_log_format_validator/_VALID_LOG_FORMATSpattern — raisingValueErrorwhich dotenvmodel wraps asConstraintViolationError.ge=0.1,ge=0.01) match existingge=usage on other float fields.croniteris already a core dependency, imported at module level._hh_mm_validatorand_cron_expr_validatorare reusable —ctx.field_nameproduces the correct field name in each error message.Verification
33 new tests cover valid values, invalid values, boundary conditions, and case-insensitivity for each field.