Repository navigation
fix: reject unknown config keys - #281
Conversation
Forbid extra fields in all models of the custom config (base class ConfigModel), so that misspelled or removed keys in config overlays stop the app and the Celery worker on startup instead of being ignored (e.g., tes.servce_list left the list of backends empty). Remove the unused models Celery and Monitor and the keys custom.celery (not a field, silently dropped) and custom.controllers.celery. Closes #276 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes: list the removed keys by full path in the upgrade notes, name the camelCase storeLogs in the docstring, and reuse the helper for the base config in the tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR makes custom configuration strict by applying Pydantic extra-field rejection across all models, removes obsolete Celery settings, adds comprehensive validation coverage for base and example configurations, and documents the resulting startup and upgrade behavior. Sequence diagram for strict custom configuration startup validationsequenceDiagram
participant App
participant Worker as CeleryWorker
participant Config as CustomConfig
participant Pydantic
App->>Config: model_validate(config)
Config->>Pydantic: validate extra fields
alt unknown key
Pydantic-->>Config: ValidationError
Config-->>App: failed validating custom configuration
App-->>App: refuse startup
else valid configuration
Pydantic-->>Config: validated CustomConfig
Config-->>App: configuration accepted
end
Worker->>Config: model_validate(config)
Config->>Pydantic: validate extra fields
alt unknown key
Pydantic-->>Config: ValidationError
Config-->>Worker: failed validating custom configuration
Worker-->>Worker: refuse startup
else valid configuration
Pydantic-->>Config: validated CustomConfig
Config-->>Worker: configuration accepted
end
Flow diagram for rejected unknown configuration keysflowchart TD
A[Load custom configuration overlay] --> B[Validate with CustomConfig]
B --> C{Unknown key?}
C -->|No| D[Start app or Celery worker]
C -->|Yes| E[Raise Pydantic ValidationError]
E --> F[Fail custom configuration validation]
F --> G[Refuse startup]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #281 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 28 28
Lines 2096 2092 -4
=========================================
- Hits 2096 2092 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pro_tes/config_models.py" line_range="153-180" />
<code_context>
return self
-class Monitor(BaseModel):
- """Celery monitor settings.
-
- Args:
- timeout: Timeout to wait for Celery monitoring.
</code_context>
<issue_to_address>
**Documented Python model imports break**
When a downstream consumer imports either model from `pro_tes.config_models`, `from pro_tes.config_models import Celery, Monitor` raises `ImportError` because both documented model classes are removed; downstream callers that imported them can no longer load.
Retain the symbols as deprecated compatibility aliases or document the Python API break and its replacement.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and an existing overlay with a formerly ignored key, including one of the removed Celery settings, can now prevent the app and worker from starting. Reverting restores startup, but it cannot recover service time already lost.
Blocking findings: pro_tes/config_models.py:180
Summary
Unknown keys in the custom config are now errors (pre-release review of v0.3.0, finding 9):
ConfigModelwithextra="forbid", so misspelled or removed keys in config overlays stop the app and the Celery worker on startup (FOCA raisesfailed validating custom configuration, chained from the pydantic error that names the key), instead of being ignored. Example:tes.servce_listused to leave the list of backends empty.CeleryandMonitorand the keyscustom.celery(not a field, so it was silently dropped) andcustom.controllers.celeryare removed.custom.controllers.post_task.timeoutis replaced by a working timeout in fix: submit tasks to backends exactly once #274 (separate PR), so it still validates here.docs/configuration.mdanddocs/upgrading.mddescribe the change.Verification
pre-commit run --all-files(ruff, ruff format, mypy and the other hooks): passedcoverage run -m pytest(mongomock): 822 passed, 81 skipped (helm chart tests, helm not installed locally);coverage report: 100%MONGODB_TEST_URI=... pytestagainst MongoDB 7.0: 822 passed, 81 skippedmkdocs build --strict: passedtests/test_config_examples.py). The existing examples of the docs and the chart's values still validate.config.dev.yaml, test and smoke overlays, chart values and CI values, docs examples) validate, that registry data is never passed to the models as a whole, and that the worker refuses to start with an unknown key. The low findings were fixed: full key paths in the upgrade notes, the camelCasestoreLogsnamed in the docstring, and a shared test helper.Declined review findings
CeleryandMonitoras deprecated aliases for Python importers. Declined:pro_tes.config_modelsis not a public API, and this is the first release. The config break is documented indocs/upgrading.md(replied in the thread).Open questions
None.
Closes #276
🤖 Generated with Claude Code