Perf/batch endpoints parallel analyzers#34
Merged
Conversation
…miter Both batch endpoints were missing the `http_request: Request` parameter required by slowapi to extract the client IP for rate limiting, causing a startup crash on deploy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
This PR updates the FastAPI service to make the /health endpoint “fail-open” (always HTTP 200) for deployment healthchecks, and adjusts batch scan endpoints to accept a Request object (likely to support rate limiting).
Changes:
- Add a
/healthspecial-case in the global exception handler to return HTTP 200 with a degraded payload. - Wrap
/healthhandler logic intry/exceptand hide it from the OpenAPI schema (include_in_schema=False). - Update
/api/scan/batch-resultsand/api/scan/batch-statussignatures to acceptrequest: Request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """ | ||
| # Never return 503 for /health so Railway healthchecks don't fail the deploy | ||
| if request.url.path == "/health": | ||
| logger.error("Error during /health: %s", exc) |
Comment on lines
+196
to
+197
| "detail": SERVICE_UNAVAILABLE_MESSAGE, | ||
| "error_code": "SERVICE_HEALTH_DEGRADED", |
Comment on lines
+3475
to
+3476
| except Exception as exc: | ||
| logger.error("Health check internal error: %s", exc) |
Comment on lines
+3466
to
+3482
| try: | ||
| uptime_seconds = int((datetime.now(timezone.utc) - _health_start_time).total_seconds()) | ||
| flags = get_feature_flags() | ||
| return { | ||
| "status": "healthy", | ||
| "version": "1.0.0", | ||
| "uptime_seconds": uptime_seconds, | ||
| "mode": flags.mode, | ||
| } | ||
| except Exception as exc: | ||
| logger.error("Health check internal error: %s", exc) | ||
| return { | ||
| "status": "degraded", | ||
| "version": "1.0.0", | ||
| "uptime_seconds": 0, | ||
| "mode": "unknown", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.