feat(express): add zod validation for scope and lanes HTTP routes#10454
feat(express): add zod validation for scope and lanes HTTP routes#10454davidfirst wants to merge 9 commits into
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 |
Adds input validation to the remote-scope HTTP protocol routes, turning malformed requests into clear
400s instead of cryptic500s deep in the stack, and hardening the network-exposed write surface.What's new
A shared helper in
@teambit/express:validateBody(schema)— middleware that validatesreq.bodyand responds400on failure.validateData(schema, data, label)— for non-body input (used for the put route header).HttpError— error carrying an HTTP status (honored by the existing error handler).Routes covered
put(safeJSON.parse+ schema for thepush-optionsheader),delete,action,fetch.create,delete,restore,check-conflicts— replaced the ad-hocif (!x) res.status(400)checks with declarative schemas. Preserved special cases (delete's empty-array →204).Design note
All schemas are permissive (
.passthrough(), never.strict()) and validate only the fields each route reads. These routes talk to clients of varying Bit versions, and the options objects carry deprecated/version-gated fields, so strict validation would break cross-version compatibility.The local api-server routes (
cli,ide,component, etc.) are intentionally left out — they're a localhost/same-machine trust boundary, not the network protocol.