feat(client): add LENGTH_REQUIRED (411) to common error codes - #2114
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
COMMON_ERROR_STATUS_MAPgainsLENGTH_REQUIRED: 411— fills the gap betweenGONE(410) andPRECONDITION_FAILED(412); autocompletes as anORPCErrorCodeand gives both handlers a default 411 status.- Malformed-response inference — no code change needed; the reverse lookup in
inferMalformedResponseMessage(packages/client/src/error-utils.ts:95) now resolves 411 to "Length Required". - New test assertion — pins the 411 message inference in
error-utils.test.ts. - Docs tables — adds the
LENGTH_REQUIRED | 411row to the RPC and OpenAPI handler error-code tables, the only two mirrors of the map.
The test is meaningful: without the map entry, 411 has no reverse match, the message stays undefined, and ORPCError falls back to "Malformed Orpc Response" — so the assertion fails pre-change. The only other consumers of the map (retry-after.ts, handler codecs, the OpenAPI generator) are unaffected by an added key, and "Length Required" matches the RFC 9110 reason phrase.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
`COMMON_ERROR_STATUS_MAP` jumped from GONE (410) to PRECONDITION_FAILED (412), so throwing `LENGTH_REQUIRED` for a missing `Content-Length` on streamed uploads needed a manual `status: 411`, and a malformed 411 response fell back to the generic message instead of "Length Required".
4b4a67e to
3f5cb15
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/experimental-lock
@orpc/experimental-msw
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
Merging this PR will degrade performance by 12.67%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | octet stream |
640.5 µs | 733.4 µs | -12.67% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing michealroberts:feat/client-length-required-411 (3f5cb15) with main (94f55fd)

COMMON_ERROR_STATUS_MAPskipped 411, jumping fromGONE(410) toPRECONDITION_FAILED(412). ThrowingLENGTH_REQUIREDfor a streamed upload without aContent-Lengththerefore needednew ORPCError('LENGTH_REQUIRED', { status: 411 }), and a malformed 411 response from a server fell back to the generic error message.Changes
LENGTH_REQUIRED: 411toCOMMON_ERROR_STATUS_MAP, so it autocompletes as anORPCErrorCodeand both handlers respond with 411 by default.createORPCErrorFromMalformedResponsenow infers the message "Length Required" for 411 responses.Testing
error-utils.test.ts.tsc, and lint pass.