Skip to content

Include header name in encoding error message#3767

Open
Fridayai700 wants to merge 1 commit intoencode:masterfrom
Fridayai700:fix-header-encoding-error-message
Open

Include header name in encoding error message#3767
Fridayai700 wants to merge 1 commit intoencode:masterfrom
Fridayai700:fix-header-encoding-error-message

Conversation

@Fridayai700
Copy link

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 encode#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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mention header name error message for invalid header encodings

1 participant

Comments