fix(convex): cast request.json() in HTTP actions for TS compatibility#2525
fix(convex): cast request.json() in HTTP actions for TS compatibility#2525
Conversation
Convex's TS environment types request.json() as unknown. Add 'as typeof body/update' casts to fix the 4 type errors that blocked deployment.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThis PR adds four Changes:
Confidence Score: 5/5Safe to merge — purely compile-time fix with no runtime behaviour change. All four changes are TypeScript-only assertions that carry no runtime cost or risk. Each handler already guards against malformed input through explicit runtime validation after the parse. The No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Router as Convex HTTP Router
participant Handler as httpAction Handler
participant Backend as ctx.auth / runMutation / runQuery
Client->>Router: POST request with JSON body
Router->>Handler: passes request object
Handler->>Handler: request.json() as typeof body
note right of Handler: Type cast (compile-time only)
alt JSON parse error
Handler-->>Client: 400 response
end
Handler->>Handler: runtime field validation
alt Fields missing or wrong type
Handler-->>Client: 400 response
end
Handler->>Backend: auth check + mutation/query
Backend-->>Handler: result
Handler-->>Client: success response
Reviews (1): Last reviewed commit: "fix(convex): cast request.json() return ..." | Re-trigger Greptile |
Summary
Convex's TypeScript environment types
request.json()asunknown, stricter than our localtsconfig.json. This caused 4 type errors that blockedconvex deploy:convex/http.ts:86— user-prefs POST bodyconvex/http.ts:156— telegram-pair-callback updateconvex/http.ts:201— relay/deactivate bodyconvex/http.ts:247— relay/channels bodyFix:
await request.json() as typeof body/updateon each assignment.Post-Deploy Monitoring & Validation
No additional operational monitoring required: type-only fix, no runtime behavior change.