Repository navigation
fix(api): carry Allow on the TypeScript handlers' 405 responses - #9882
ayobamiseun wants to merge 1 commit into
Conversation
Follow-up to the eight primary entry points and the six legacy JS handlers. RFC 9110 §15.5.6 requires a 405 to name the supported methods; twenty TypeScript handlers still answered without `Allow`: latest-brief, chat-analyst, customer-portal, invalidate-user-api-key-cache, channel-oauth-bind, notify, create-checkout, widget-agent, symbol-search, notification-channels, referral/me, oauth/token, internal/brief-why-matters, brief/share-url, skills/fetch-agentskills, the three brief document routes and the two v2 shipping webhook routes. Each guard now carries `Allow` equal to the methods the handler actually accepts (its preflight list where it has one). Bodies, status codes and other headers are unchanged; oauth/token and brief-why-matters build the same response they did with the header added. A new suite drives all twenty handlers with a refused method. widget-agent and notification-channels authenticate before their method guard, so the suite supplies the widget key and a stubbed bearer session through the handler's test seam. Where the handler answers OPTIONS with the same list the preflight is checked too. Red proof: with the handler edits stashed, the 20 refusal cases fail and the 14 preflight cases stay green.
|
@ayobamiseun is attempting to deploy a commit to the World Monitor Team on Vercel. A member of the Team first needs to authorize it. |
Strix Security Review✅ No open security findings. PR summary: This PR adds the RFC 9110–required `Allow` header to the 405 method-not-allowed responses of twenty TypeScript API handlers under `api/`, and adds a test suite asserting the header (and preflight method list) for each handler. Review summaryReviewed all 21 changed files. The diff is confined to adding a static Review 1 on this PR · Reviewed by Strix |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
405 responses and coverage api/brief/[userId]/[issueDate].ts, api/brief/carousel/[userId]/[issueDate]/[page].ts, api/brief/public/[hash].ts, api/brief/share-url.ts, api/channel-oauth-bind.ts, api/chat-analyst.ts, api/create-checkout.ts, api/customer-portal.ts, api/internal/brief-why-matters.ts, api/invalidate-user-api-key-cache.ts, api/latest-brief.ts, api/notification-channels.ts, api/notify.ts, api/oauth/token.ts, api/referral/me.ts, api/skills/fetch-agentskills.ts, api/symbol-search.ts, api/v2/shipping/webhooks/[subscriberId].ts, api/v2/shipping/webhooks/[subscriberId]/[action].ts, api/widget-agent.ts, tests/api-405-allow-header-ts.test.mjs |
The handlers add endpoint-specific Allow headers to their 405 responses. The new tests check the expected header values and selected OPTIONS preflight responses. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Possibly related PRs
- koala73/worldmonitor#9881: Adds
Allowheaders to 405 responses in six legacy JavaScript handlers. - koala73/worldmonitor#9876: Adds
Allowheaders to other handlers as part of the same API method-contract update. - koala73/worldmonitor#8378: Changes the CORS method configuration for the shipping webhook action handler, which this PR also updates.
Suggested reviewers: koala73
Merge Risk: 
Minimal · up to 7ff6d
-
The handlers advertise their supported methods in 405 responses. No merge-blocking issue was identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description provides a detailed summary, affected handlers, method mappings, test coverage, verification results, and implementation notes. It omits some template headings and checklist selections, but the required change context and validation details are substantially complete.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 20 functions across 21 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
[Medium impact] This PR appears safe to merge. SummaryAdds
Reviews (1) · Last reviewed commit: "fix(api): carry Allow on the TypeScript ..." · Reviewed by Greptile |
|
Reviewed exact head No verified code defect found. All twenty advertised method lists match their guards; the rewritten HTML/JSON responses preserve their bodies, status and cache headers. Node 24 focused handler proof passes 34/34, Feedback review found no unresolved inline thread. The automated request for docstrings on twenty unchanged handler bodies would add unrelated churn to a header-only correction, so I am leaving that advisory unchanged. GitHub reports MERGEABLE. Required checks pass, while the Vercel status is failed because the contributor deployment needs team authorization. I have not authorized that gate. Sequential correctness, testing, maintainability, standards, agent-accessibility, security/API, adversarial and prior-feedback lenses were performed in this chat. No independent cross-model review ran under this lane's no-subagent constraint; this is not an independent approval or a claim of full merge readiness. |
Summary
Follow-up to #9876 (eight primary entry points) and #9881 (six legacy JS handlers). RFC 9110 §15.5.6 requires a 405 response to name the supported methods in
Allow. Twenty TypeScript handlers still answered without it. With this PR every single-line 405 site underapi/andserver/carries the header.latest-brief.ts,symbol-search.ts,referral/me.tsGET, OPTIONSchat-analyst.ts,invalidate-user-api-key-cache.ts,notify.ts,create-checkout.ts,brief/share-url.ts,skills/fetch-agentskills.ts,oauth/token.ts,v2/shipping/webhooks/[subscriberId]/[action].tsPOST, OPTIONScustomer-portal.ts,widget-agent.ts,notification-channels.tsGET, POST, OPTIONSbrief/carousel/…,brief/public/[hash].ts,brief/[userId]/[issueDate].tsGET, HEAD, OPTIONSv2/shipping/webhooks/[subscriberId].tsGET, DELETE, OPTIONSchannel-oauth-bind.ts,internal/brief-why-matters.ts(no CORS preflight)POSTBodies, status codes and other headers are unchanged.
oauth/token.tsandinternal/brief-why-matters.tsnow build the same response inline so the header can be added (their local helpers take no headers argument).Tests
New
tests/api-405-allow-header-ts.test.mjsdrives all twenty handlers with a refused method and assertsAllow. Where the handler answers OPTIONS with the same list, the preflight'sAccess-Control-Allow-Methodsis checked too.widget-agentandnotification-channelsauthenticate before their method guard, so the suite supplies the widget key via env and a stubbed bearer session through__setNotificationChannelsDepsForTests.Red proof: with the handler edits stashed, the 20 refusal cases fail and the 14 preflight cases stay green.
Verification
tests/api-405-allow-header-ts.test.mjs— 34 passnpm run typecheck:api,git diff --check— clean; the one Biome info onsymbol-search.ts:175predates this changeSummary by CodeRabbit
Allowheader listing the methods accepted by each endpoint. Existing error statuses and messages remain unchanged.