Defer Settings credential validation to daemon startup#90
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughMoves credential validation out of import time into ChangesRuntime validation refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant __main__.py
participant Settings
participant Logger
__main__.py->>Settings: validate_for_run()
alt invalid configuration
Settings-->>__main__.py: raise ConfigurationError
__main__.py->>Logger: log error message
__main__.py->>__main__.py: exit(1)
else valid configuration
Settings-->>__main__.py: return
end
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_config.py`:
- Around line 25-42: Suppress the Ruff S105/S106 false positives in the test
fixture values used by Settings tests, since the literals in
test_settings_accepts_slack_when_not_testing and
test_settings_rejects_blank_database_url are dummy data. Either add the
appropriate per-line noqa on the hardcoded token/secret assertions in
tests/test_config.py, or configure a tests/** per-file ignore for S105/S106 in
the project lint settings so these test-only constants don’t fail CI.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b0f5a4c1-41f0-45f8-83d5-6292b1559f49
📒 Files selected for processing (9)
.env.example.github/workflows/cd.yml.github/workflows/ci.ymlCONTRIBUTING.mdbenchmarks/conftest.pysrc/paperscout/__main__.pysrc/paperscout/config.pytests/conftest.pytests/test_config.py
💤 Files with no reviewable changes (3)
- CONTRIBUTING.md
- .github/workflows/cd.yml
- .github/workflows/ci.yml
wpak-ai
left a comment
There was a problem hiding this comment.
Should fix
tests/test_config.py:56,63,71,79,97,107— remove the six dead_PAPERSCOUT_TESTINGmonkeypatches.tests/test_config.py:45(test_settings_constructs_with_empty_defaults) — not.env-hermetic;delenvonly clears process env whileconfigreads.env, so a dev whose.envhasSLACK_*(i.e. anyone who copied.env.example) gets false failures. Pass_env_file=<empty tmp>like the sibling dotenv tests.
- Remove 6 dead _PAPERSCOUT_TESTING monkeypatches - test_settings_constructs_with_empty_defaults hermeticity
Summary
@model_validatorthat required_PAPERSCOUT_TESTING=1whenever Slack credentials were blank, sofrom paperscout.config import settingsalways succeeds with safe defaults.Settings.validate_for_run()to raiseConfigurationErrorwhenslack_bot_token,slack_signing_secret, ordatabase_urlare missing, and call it from__main__.pybeforeinit_pool()(replacing the previousdatabase_url-only guard)._PAPERSCOUT_TESTINGfromtests/conftest.py,benchmarks/conftest.py, CI/CD workflows,.env.example, andCONTRIBUTING.md.tests/test_config.pyto assert validation viavalidate_for_run()instead of construction-time failures.Addresses week 2 plan item T3 (Test 9 — Settings defaults requiring a hidden testing flag).
Test plan
uv run pytest -q(414 passed)uv run mypy src/paperscout/config.py src/paperscout/__main__.pyuv run ruff check src testspython -c "from paperscout.config import settings"succeeds with no env varspython -m paperscoutexits with a clear error when Slack/DB credentials are missing./run check(ormake check)pre-commit run --all-filesRelated issues
Settingsdefaults usable without_PAPERSCOUT_TESTING; move credential validation out of import time #89Summary by CodeRabbit