Skip to content

Stage 2: Add FastAPI shell with Flask fallback #3642

@anth-volk

Description

@anth-volk

Goal

Implement Stage 2 of the API v2-alpha migration plan: add a FastAPI ASGI shell that can host the existing Flask API through WSGI fallback without changing the public API contract.

Targets

  • Add a FastAPI ASGI entrypoint.
  • Mount the existing Flask app behind FastAPI with WSGI middleware.
  • Preserve representative v1 behavior through fallback, including status codes, bodies, headers, CORS, cookies, and country-ID validation.
  • Add a native /health endpoint under ASGI.
  • Keep production traffic on App Engine/Flask for this PR.
  • Avoid schema, database, Supabase, Cloud Run, and native route migration changes.

Additional compatibility work

  • Handle budget-window submission-time Modal 4xx validation errors as structured budget-window error results, so staging can tolerate the newer simulation gateway validation behavior while preserving 5xx failures as real errors.

Success criteria

  • Existing representative v1 route contracts pass through both Flask direct and FastAPI fallback clients.
  • /health returns 200 under ASGI.
  • Existing Flask readiness/liveness routes still fall through unchanged.
  • No production traffic shift is introduced by this PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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