Skip to content

[Good First Issue] Add bbox coordinate validation to PredictRequest #18

@Oshgig

Description

@Oshgig

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

  • Add Pydantic validators to PredictRequest.bbox in src/climatevision/api/schemas.py (or main.py if schemas are inline)
  • Validate:
    • Exactly 4 elements: [west, south, east, north]
    • -180 <= longitude <= 180
    • -90 <= latitude <= 90
    • west < east and south < north
  • Return a clear 422 Unprocessable Entity with descriptive error message
  • Add pytest test in tests/test_api.py covering at least 3 invalid cases and 1 valid case

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.pyPredictRequest schema
  • tests/test_api.py — existing API tests
  • Pydantic field_validator docs

Difficulty: Beginner-friendly
Labels: good first issue, backend, api, validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions