What
If a header value coming from ANTHROPIC_CUSTOM_HEADERS, an API key environment variable, or apiKeyHelper is not a legal HTTP header value, Claude Code now fails with a clear error before sending, classified as your mistake rather than an internal crash.
Details
- New
InvalidRequestHeaderValueError, classified asinvalid_request_headerorinvalid_api_keywhen the value is user-supplied. - Logged at error level rather than reported as a crash.
- Treated as non-retryable during API key verification, so a malformed key value fails immediately.
- The error class does not exist in v2.1.226.
Evidence
request header value rejected before send: not a valid HTTP header value
Strings lifted out of the shipped bundle, so the claim above can be checked against them.
Names in the bundleANTHROPIC_CUSTOM_HEADERSapiKeyHelper