Skip to content

feat(client): add LENGTH_REQUIRED (411) to common error codes - #2114

Merged
dinwwwh merged 1 commit into
middleapi:mainfrom
michealroberts:feat/client-length-required-411
Sep 28, 2026
Merged

dinwwwh merged 1 commit into
middleapi:mainfrom
michealroberts:feat/client-length-required-411

Conversation

@michealroberts

@michealroberts michealroberts commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

COMMON_ERROR_STATUS_MAP skipped 411, jumping from GONE (410) to PRECONDITION_FAILED (412). Throwing LENGTH_REQUIRED for a streamed upload without a Content-Length therefore needed new ORPCError('LENGTH_REQUIRED', { status: 411 }), and a malformed 411 response from a server fell back to the generic error message.

Changes

  • Add LENGTH_REQUIRED: 411 to COMMON_ERROR_STATUS_MAP, so it autocompletes as an ORPCErrorCode and both handlers respond with 411 by default.
  • createORPCErrorFromMalformedResponse now infers the message "Length Required" for 411 responses.
  • Add the code to the error-code tables in the RPC and OpenAPI handler docs.

Testing

  • New assertion for the 411 message inference in error-utils.test.ts.
  • Root vitest (3528 tests), tsc, and lint pass.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • COMMON_ERROR_STATUS_MAP gains LENGTH_REQUIRED: 411 — fills the gap between GONE (410) and PRECONDITION_FAILED (412); autocompletes as an ORPCErrorCode and 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 | 411 row 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.

Pullfrog  | View workflow run | Using 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".
@michealroberts
michealroberts force-pushed the feat/client-length-required-411 branch from 4b4a67e to 3f5cb15 Compare September 28, 2026 13:21
@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pkg-pr-new

pkg-pr-new Bot commented Sep 28, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@2114

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@2114

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@2114

@orpc/client

npm i https://pkg.pr.new/@orpc/client@2114

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@2114

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@2114

@orpc/experimental-effect

npm i https://pkg.pr.new/@orpc/experimental-effect@2114

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@2114

@orpc/hibernation

npm i https://pkg.pr.new/@orpc/hibernation@2114

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@2114

@orpc/experimental-lock

npm i https://pkg.pr.new/@orpc/experimental-lock@2114

@orpc/experimental-msw

npm i https://pkg.pr.new/@orpc/experimental-msw@2114

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@2114

@orpc/next

npm i https://pkg.pr.new/@orpc/next@2114

@orpc/node

npm i https://pkg.pr.new/@orpc/node@2114

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@2114

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@2114

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@2114

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@2114

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@2114

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@2114

@orpc/server

npm i https://pkg.pr.new/@orpc/server@2114

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@2114

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@2114

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@2114

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@2114

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@2114

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@2114

commit: 3f5cb15

@codspeed

codspeed Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 12.67%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 29 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

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)

Open in CodSpeed

@dinwwwh
dinwwwh merged commit 36b8bd9 into middleapi:main Sep 28, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants