fix: validate sophia maintenance limits#5720
Conversation
TJCurnutte
left a comment
There was a problem hiding this comment.
Approved. The maintenance routes now validate limit before invoking the review backfill/normalization helpers, so bad client input returns a controlled 400 instead of leaking into helper-side coercion or silently accepting zero/negative limits.
Validation run on detached PR worktree at dcb08cabd67c963d98ebf5c22e35138f0f5bc64b:
git diff --check origin/main...HEAD -- node/sophia_governor_review_service.py node/tests/test_sophia_governor_review_service.py
python3 -B -m py_compile node/sophia_governor_review_service.py node/tests/test_sophia_governor_review_service.py
RC_ADMIN_KEY=test-admin PYTHONPATH=node python3 -B -m pytest -q node/tests/test_sophia_governor_review_service.py --tb=short -p no:cacheproviderResult: 25 passed, 1 warning in 0.19s.
I also ran direct temp-DB Flask probes against both /api/sophia/governor/review/backfill-missing and /api/sophia/governor/review/normalize-existing: limit="abc" and limit="10.5" now return HTTP 400 limit must be an integer; limit=0 and limit=-1 return HTTP 400 limit must be at least 1; valid/capped values (1, 250) still return HTTP 200. The same probe on origin/main returned HTTP 500 for malformed string limits and accepted 0/-1 with HTTP 200, so this is a concrete stability/validation improvement.
minyanyi
left a comment
There was a problem hiding this comment.
Validated the maintenance-limit normalization on current head.
What I checked on dcb08ca:
- both maintenance endpoints now route through the same integer clamp/validation helper instead of accepting arbitrary JSON values
- non-integer values (
"abc","10.5") and non-positive values (0,-1) now fail fast with explicit 400 errors - the targeted regression suite passes locally:
python -B -m pytest -q node/tests/test_sophia_governor_review_service.py --tb=short->25 passed
The scope is tight and the test coverage matches the behavior change. LGTM.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Great work on this PR. 🚀
Review: changes requestedI reviewed PR #5720 ( Validation run:
Finding: The new Minimal repro: So a JSON numeric float such as Suggested fix:
Please add regression coverage for at least |
|
Reviewed the Sophia governor review maintenance limit validation change. What I verified: The new helper rejects malformed and non-positive maintenance limits before calling the backfill/normalize routines, while preserving the existing default and upper clamp behavior. The route-level coverage checks both maintenance endpoints. No blocker found in this pass. |
Summary
limitvalues before calling Sophia review helpersCloses #4400
Tests
uv run --with pytest --with flask --with requests python -B -m pytest -q node/tests/test_sophia_governor_review_service.py --tb=short -p no:cacheproviderpython3 -B -m py_compile node/sophia_governor_review_service.py node/tests/test_sophia_governor_review_service.pygit diff --check