Overview
The PredictRequest schema accepts a bbox field but does not validate that the coordinates are geographically valid. A malformed bbox (e.g., lat > 90, lon > 180, or min > max) causes a silent failure or confusing error during GEE querying.
Scope
Acceptance Criteria
POST /api/predict with bbox: [200, 10, 30, 40] returns 422 with "Invalid longitude: 200"
POST /api/predict with bbox: [-60, -15, -45, -5] succeeds as before
- All new tests pass in CI
Resources
src/climatevision/api/main.py — PredictRequest schema
tests/test_api.py — existing API tests
- Pydantic
field_validator docs
Difficulty: Beginner-friendly
Labels: good first issue, backend, api, validation
Overview
The
PredictRequestschema accepts abboxfield but does not validate that the coordinates are geographically valid. A malformed bbox (e.g., lat > 90, lon > 180, or min > max) causes a silent failure or confusing error during GEE querying.Scope
PredictRequest.bboxinsrc/climatevision/api/schemas.py(ormain.pyif schemas are inline)[west, south, east, north]-180 <= longitude <= 180-90 <= latitude <= 90west < eastandsouth < north422 Unprocessable Entitywith descriptive error messagetests/test_api.pycovering at least 3 invalid cases and 1 valid caseAcceptance Criteria
POST /api/predictwithbbox: [200, 10, 30, 40]returns422with "Invalid longitude: 200"POST /api/predictwithbbox: [-60, -15, -45, -5]succeeds as beforeResources
src/climatevision/api/main.py—PredictRequestschematests/test_api.py— existing API testsfield_validatordocsDifficulty: Beginner-friendly
Labels:
good first issue,backend,api,validation