fix(scope): return 400 on missing/invalid push-options header#10454
Conversation
PR Summary by QodoAdd shared zod validation to remote scope/lanes HTTP routes Description
Diagram
High-Level Assessment
Files changed (11)
|
Code Review by Qodo
1.
|
|
Code review by qodo was updated up to the latest commit 891c351 |
|
@qodo Thanks — addressed the 4xx logged as errors finding in 987958b.
|
Looks good — thanks for the update.
No further action needed from my side. |
|
Code review by qodo was updated up to the latest commit 987958b |
|
Code review by qodo was updated up to the latest commit 812084a |
|
Code review by qodo was updated up to the latest commit 145bd35 |
|
Code review by qodo was updated up to the latest commit 8e23da2 |
|
Code review by qodo was updated up to the latest commit ea5e648 |
|
Code review by qodo was updated up to the latest commit d0347da |
Trim the validation PR down to the one contract-free robustness fix: parse the push-options header safely and return a clear 400 instead of a 500. Dropped the zod body schemas on the scope/lanes protocol routes - they added a second source of truth that must stay backward-compatible across client/server versions, with little benefit since the schemas were deliberately permissive.
|
Code review by qodo was updated up to the latest commit 783dbd0 |
There was a problem hiding this comment.
Pull request overview
This PR improves robustness of the scope /scope/put HTTP route by avoiding an internal 500 when the push-options header is missing or malformed, instead returning a clear 400 response.
Changes:
- Return
400whenpush-optionsheader is missing. - Catch JSON parsing errors for
push-optionsand return400instead of throwing.
| const pushOptionsStr = req.headers['push-options']; | ||
| if (!pushOptionsStr) throw new Error('http is missing the push-options header'); | ||
| const pushOptions = JSON.parse(pushOptionsStr as string); | ||
| if (!pushOptionsStr) { | ||
| return res.status(400).send('http is missing the push-options header'); | ||
| } | ||
| let pushOptions; |
|
Code review by qodo was updated up to the latest commit cc80f12 |
…n master These files diverged from master via earlier automated master-merges (they carried #10454 and a 2.0.3 version bump that current master no longer has). Restore them to master so this PR contains only the export clientId change.
Earlier I reverted these as 'orphaned', but #10454 and the 2.0.3 bump have since landed on master — so the revert left .bitmap stale against the merged components, causing Consumer.setBitMap to read defaultScope of undefined in dogfooding tests. Sync them back to current master.
Parse the
push-optionsheader in the scopeputroute safely: return a clear400when the header is missing or isn't valid JSON, instead of surfacing a cryptic500from deep in the stack.Background
This PR originally added zod validation across the scope/lanes remote-scope protocol routes. We decided against that: these routes are a versioned wire protocol (client and server upgrade independently), so each schema becomes a second source of truth that must stay backward-compatible forever, with asymmetric downside (a too-strict server rejects lagging clients) and little upside given the schemas were deliberately permissive. So it's trimmed down to the one contract-free robustness fix.