Skip to content

feat: Make FastAPI the primary entry point for all deployments (#13986) - #14109

Closed
Sravan1011 wants to merge 2 commits into
internetarchive:masterfrom
Sravan1011:feature/fastapi-primary-entrypoint-13986
Closed

Sravan1011 wants to merge 2 commits into
internetarchive:masterfrom
Sravan1011:feature/fastapi-primary-entrypoint-13986

Conversation

@Sravan1011

Copy link
Copy Markdown
Contributor

Enable the fallback proxy in production so that new FastAPI endpoints are automatically reachable without maintaining path patterns in olsystem's nginx config.

Changes:

  • asgi_app.py: Remove the LOCAL_DEV/testing deployment gate from the catch-all fallback route. FastAPI now proxies unmatched requests to web.py in all deployments.
  • proxy.py: Harden for production use:
    • Add finite PROXY_TIMEOUT (5s connect, 300s read/write) to prevent hung web.py responses from blocking FastAPI workers forever
    • Catch httpx.TimeoutException and return 504 Gateway Timeout
    • Tag proxied requests with sentry_sdk.set_tag('proxied', True) for observability
    • Add structured logging for timeout events
  • prometheus.py: Exclude the catch-all /{path:path} handler from FastAPI's Prometheus metrics to prevent it dominating per-route latency buckets. Web.py's own metrics (server=webpy) still provide per-route breakdown.
  • test_proxy.py: Add tests for timeout handling (ReadTimeout, ConnectTimeout → 504), PROXY_TIMEOUT finite values, and Sentry tagging of proxied requests.

Refs: #13986, #13423, #13516

Closes ##13986

…netarchive#13986)

Enable the fallback proxy in production so that new FastAPI endpoints are
automatically reachable without maintaining path patterns in olsystem's
nginx config.

Changes:
- asgi_app.py: Remove the LOCAL_DEV/testing deployment gate from the
  catch-all fallback route. FastAPI now proxies unmatched requests to
  web.py in all deployments.
- proxy.py: Harden for production use:
  - Add finite PROXY_TIMEOUT (5s connect, 300s read/write) to prevent
    hung web.py responses from blocking FastAPI workers forever
  - Catch httpx.TimeoutException and return 504 Gateway Timeout
  - Tag proxied requests with sentry_sdk.set_tag('proxied', True) for
    observability
  - Add structured logging for timeout events
- prometheus.py: Exclude the catch-all /{path:path} handler from
  FastAPI's Prometheus metrics to prevent it dominating per-route
  latency buckets. Web.py's own metrics (server=webpy) still provide
  per-route breakdown.
- test_proxy.py: Add tests for timeout handling (ReadTimeout,
  ConnectTimeout → 504), PROXY_TIMEOUT finite values, and Sentry
  tagging of proxied requests.

Refs: internetarchive#13986, internetarchive#13423, internetarchive#13516
@openlibrary-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR, @Sravan1011!

🤖 A reviewer has been assigned for an initial pass.

PR triage checklist (maintainers / Pierre)
  • PR description — not empty; explains what the change does and how to verify it
  • References an issue — PR body contains a #NNN reference
    • Linked issue is triaged — has a Priority: * label (not just Needs: Triage)
    • Linked issue is assigned — has at least one assignee
  • Commit history clean — no WIP/fixup/conflict noise; commit messages are meaningful
  • CI passing — no failing check-runs
  • Test cases present — if the change touches substantive logic, test coverage exists or is explained
  • Proof of testing — PR body includes a description of what was tested, a screenshot, or a video

Note

This comment was automatically generated by Pierre, Open Library's PR first-touch assistant, on behalf of @mekarpeles. This is NOT a code review or sign-off.

@Sravan1011

Copy link
Copy Markdown
Contributor Author

@lokesh @RayBB can you review this PR

@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label Oct 29, 2026
@Sravan1011

Copy link
Copy Markdown
Contributor Author

@RayBB can you review this pr

@RayBB

RayBB commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Please follow our contributing guidelines and work on issues that are ready to be worked on

@RayBB RayBB closed this Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants