Repository navigation
fix(reader): answer OPTIONS on the topics API instead of returning 500 - #4024
Open
polylane[bot] wants to merge 1 commit into
Open
polylane[bot] wants to merge 1 commit into
polylane[bot] wants to merge 1 commit into
Conversation
Co-authored-by: polylane[bot] <277585245+polylane[bot]@users.noreply.github.com>
This branch has not been deployed
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.
The public topics API answered browser CORS preflight requests with a 500, so cross-origin clients that read topics could not load their data. The view only handled GET and POST and returned nothing for OPTIONS. After this change it answers OPTIONS with 204 and any other unsupported method with 405. The view returned None for any method it did not branch on, which Django turns into a 500. A live OPTIONS check showed both topics routes failing while the sibling find-refs view answered 204. The change adds the missing preflight and fallback responses.
Production impact at
ec9e648: Topics API keeps working; OPTIONS gains a 204 answerFix walkthrough
Watch the fix explained (1:22). Recorded for commit
ec9e648889a49acd26e38ea92dbf7e3e6eefc9ce.Full analysis
flowchart TD A["Browser on kvod-harav.com"] -->|"OPTIONS /api/topics/meat (CORS preflight)"| B["nginx: adds Access-Control-Allow-Origin"] B --> C["Django router to topics_api"] C --> D{"request.method"} D -->|"GET / POST"| E["jsonResponse (unchanged)"] D -->|"OPTIONS"| F["new branch: HttpResponse 204"] D -->|"other"| G["new branch: HttpResponseNotAllowed 405"] F --> H["preflight succeeds, follow-up GET allowed"]Detection evidence
Affected: Gcp account
production-deploymentProduction impact
The diff touches only
reader/views.py#topics_apiand a new test. It adds an OPTIONS branch and anHttpResponseNotAllowedfallback; the GET and POST bodies are untouched, so the response those requests return does not change. The deployed web pods (production-web-*, serviceweb-production) expose no provider metrics, so my observability read is empty, but the change is additive and removes aNonereturn rather than introducing a new path.Affected resources (8)
//container.googleapis.com/projects/production-deployment/locations/us-east1-b/clusters/cluster-1/k8s/default/Service/web-production//container.googleapis.com/projects/production-deployment/locations/us-east1-b/clusters/cluster-1/k8s/default/Pod/production-web-597ff6f7cb-7xb28//container.googleapis.com/projects/production-deployment/locations/us-east1-b/clusters/cluster-1/k8s/default/Pod/production-web-597ff6f7cb-bxgrl//container.googleapis.com/projects/production-deployment/locations/us-east1-b/clusters/cluster-1/k8s/default/Pod/production-web-597ff6f7cb-cwx8d//container.googleapis.com/projects/production-deployment/locations/us-east1-b/clusters/cluster-1/k8s/default/Pod/production-web-597ff6f7cb-fbp9d//container.googleapis.com/projects/production-deployment/locations/us-east1-b/clusters/cluster-1/k8s/default/Pod/production-web-597ff6f7cb-fmr47//container.googleapis.com/projects/production-deployment/locations/us-east1-b/clusters/cluster-1/k8s/default/Pod/production-web-597ff6f7cb-pnbv7//container.googleapis.com/projects/production-deployment/locations/us-east1-b/clusters/cluster-1/k8s/default/Pod/production-web-597ff6f7cb-t9qlzObservability
jsonOptions /api/topics/withjsonPayload.status=500; after the fix this stops firing for OPTIONS.Polylane assessed this pull request at
ec9e648.Causal chain
2 files changed (+38/-0)
reader/tests/topics_api_methods_test.py: added, +32/-0reader/views.py: modified, +6/-0Generated by Polylane. You can ask follow-ups by mentioning @polylane in a comment. If you close this pull request without merging, add a comment that says why. Polylane reads it to make its next fixes better.