Skip to content

fix: strip whitespace from custom headers to prevent illegal header value errors#1265

Open
TheNilesh wants to merge 1 commit intoMoonshotAI:mainfrom
TheNilesh:fix/illegal-header-value
Open

fix: strip whitespace from custom headers to prevent illegal header value errors#1265
TheNilesh wants to merge 1 commit intoMoonshotAI:mainfrom
TheNilesh:fix/illegal-header-value

Conversation

@TheNilesh
Copy link

@TheNilesh TheNilesh commented Feb 27, 2026

Description

On some Linux distributions, platform.version() can return a string with a trailing space. Since httpx (used by the OpenAI client) is strictly RFC 7230 compliant, it rejects any header values with leading or trailing whitespace, leading to an openai.APIConnectionError with the message Illegal header value.

This PR ensures that all custom headers are stripped of whitespace in _ascii_header_value before being sent.

Checklist


Open with Devin

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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.

1 participant