fix: validate external response contracts - #37
Conversation
📝 WalkthroughWalkthroughThe PR adds explicit validation for LLM and Open-Meteo payload shapes, expands retry and parsing tests, and documents the boundaries and reevaluation criteria for synchronous local persistence in asynchronous orchestration. ChangesResponse Validation
Architecture Documentation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #37 +/- ##
=======================================
Coverage 99.61% 99.62%
=======================================
Files 39 39
Lines 5787 5851 +64
Branches 330 337 +7
=======================================
+ Hits 5765 5829 +64
Misses 15 15
Partials 7 7 ☔ View full report in Codecov by Harness. |
9d3c5da to
2a33f6a
Compare
2a33f6a to
dd3a13c
Compare
|
Copilot review was requested twice during the draft phase, but GitHub reported that the requester had reached the Copilot review quota. No Copilot review threads or code findings were produced. Local verification, full diff review, and CI are clean; proceeding to the ready-state reviewer loop with this limitation recorded. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_weather_context.py (1)
29-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReuse
_is_string_keyed_dictfromweather_context.Since
_is_string_keyed_dictis already defined inweather_briefing.weather_context, consider importing it directly to avoid duplicating the logic.♻️ Proposed refactor
-def _is_string_keyed_dict(value: object) -> TypeGuard[dict[str, object]]: - return isinstance(value, dict) and all(isinstance(key, str) for key in value)(You can update the existing imports from
weather_briefing.weather_contextto include_is_string_keyed_dict, and also remove theTypeGuardimport on line 2 if it is no longer used.)🤖 Prompt for 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. In `@tests/test_weather_context.py` around lines 29 - 32, Remove the duplicate _is_string_keyed_dict definition from the test module and import _is_string_keyed_dict from weather_briefing.weather_context alongside the existing imports. Remove the TypeGuard import if it is no longer used.
🤖 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.
Nitpick comments:
In `@tests/test_weather_context.py`:
- Around line 29-32: Remove the duplicate _is_string_keyed_dict definition from
the test module and import _is_string_keyed_dict from
weather_briefing.weather_context alongside the existing imports. Remove the
TypeGuard import if it is no longer used.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5f53d1fa-8411-4fe9-8b51-b2779bf2c323
📒 Files selected for processing (7)
AGENTS.mddocs/notes.mdtests/test_llm.pytests/test_service.pytests/test_weather_context.pyweather_briefing/llm.pyweather_briefing/weather_context.py
Review-autofix completeNo unresolved, current CodeRabbit review threads were found. One trivial review-summary suggestion was independently reviewed and intentionally not applied: importing a production-private TypeGuard into the test module would couple test fixture typing to an implementation detail, while the local one-line helper is test-specific. The repository does not enforce the unrelated docstring-coverage advisory. Copilot produced no findings because the requester review quota was exhausted, as recorded above. All CI checks, local pre-commit checks, 529 tests, and source line/branch coverage are clean. |
Summary
LLMErrorso repair retries can recoverValidation
mise exec -- uv run --with pytest --with pytest-cov -- pytest --cov --cov-branch --cov-report=xml(529 passed)weather_briefingline coverage: 100%weather_briefingbranch coverage: 100%prek runScope
The synchronous SQLite observation is documented rather than refactored: under the current low-frequency, sequential workload, a threading or async database boundary would add connection-lifecycle and serialization complexity without a demonstrated latency problem.
Summary by CodeRabbit
Bug Fixes
Documentation
Tests