fix: parse OPENAI_CUSTOM_HEADERS with commas inside quoted values#9252
fix: parse OPENAI_CUSTOM_HEADERS with commas inside quoted values#9252DOsinga wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5286e2fdb2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| while i < len && chars[i] != '=' { | ||
| i += 1; |
There was a problem hiding this comment.
Stop key scan at commas when parsing malformed entries
The new parser scans for = without treating , as a segment boundary, so a malformed chunk (for example k1=v1,,k2=v2 or k1=v1,invalid,k2=v2) causes the next valid header to be merged into the previous key (e.g. ",k2" / "invalid,k2") and k2 is never parsed correctly. This is a regression from the previous implementation, which skipped invalid segments and still preserved subsequent valid headers, and it can silently send wrong header names in production when users include an accidental extra comma.
Useful? React with 👍 / 👎.
Fixes #8495 The parse_custom_headers function was splitting naively on commas, breaking header values that contain commas (e.g. x-litellm-tags="tag1,tag2"). Replace with a quote-aware parser that treats content between double quotes as a single value. Signed-off-by: Douwe Osinga <douwe@squareup.com>
5286e2f to
b87caf3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b87caf3e57
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| match ch { | ||
| '"' => in_quotes = !in_quotes, | ||
| ',' if !in_quotes => { |
There was a problem hiding this comment.
Preserve quote characters in parsed header values
The quote-handling branch toggles in_quotes but never appends " to current, so every double quote inside a header value is silently removed during parsing. This mutates legitimate values (for example structured auth parameters or JSON-like metadata) and can also mis-parse escaped-quote inputs such as x-meta="a\"b,c" by flipping quote state at the wrong time, which can corrupt subsequent key/value boundaries.
Useful? React with 👍 / 👎.
|
Superseded by #9306 which uses |
Fixes #8495
The
parse_custom_headersfunction was splitting naively on commas, breaking header values that contain commas (e.g.x-litellm-tags="tag1,tag2").This replaces the parser with a quote-aware version that treats content between double quotes as a single value.
Changes:
parse_custom_headersto handle quoted values containing commas