Skip to content

Include header name in encoding error message - #3767

Open
worksbyfriday wants to merge 1 commit into
encode:masterfrom
worksbyfriday:fix-header-encoding-error-message
Open

Include header name in encoding error message#3767
worksbyfriday wants to merge 1 commit into
encode:masterfrom
worksbyfriday:fix-header-encoding-error-message

Conversation

@worksbyfriday

Copy link
Copy Markdown

Summary

  • When a header value contains non-ASCII characters that can't be encoded, the UnicodeEncodeError now includes the header name
  • Before: 'ascii' codec can't encode characters in position 0-27: ordinal not in range(128)
  • After: 'ascii' codec can't encode characters in position 0-27: ordinal not in range(128) (header: 'auth')

Fixes #3400

Test plan

  • Added test_header_encoding_error_includes_name verifying error message contains header name
  • All 28 header model tests pass
When a header value contains non-ASCII characters that can't be encoded,
the error message now includes the header name, making it easier to
identify which header is causing the issue.

Fixes #3400

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant