Skip to content

Log warning instead of returning error when non-utf8 header passed through externalize_header_map#8828

Merged
rohan-b99 merged 9 commits intodevfrom
rohan-b99/allow-non-utf8-characters-in-headers
Jan 29, 2026
Merged

Log warning instead of returning error when non-utf8 header passed through externalize_header_map#8828
rohan-b99 merged 9 commits intodevfrom
rohan-b99/allow-non-utf8-characters-in-headers

Conversation

@rohan-b99
Copy link
Copy Markdown
Contributor

@rohan-b99 rohan-b99 commented Jan 23, 2026

  • A warning log with the name of the header will be emitted
  • The remaining valid headers will be returned now instead of an error, which is more consistent with the router's default behaviour when a coprocessor is not used.

Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

…p, return other headers so coprocessor requests still work
@rohan-b99 rohan-b99 requested a review from a team January 23, 2026 12:03
@rohan-b99 rohan-b99 requested a review from a team as a code owner January 23, 2026 12:03
@github-actions

This comment has been minimized.

@apollo-librarian
Copy link
Copy Markdown
Contributor

apollo-librarian bot commented Jan 23, 2026

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 2 changed, 0 removed
* graphos/routing/(latest)/customization/coprocessor.mdx
* graphos/routing/(latest)/customization/coprocessor/reference.mdx

Build ID: 69ac644e3da468cee087b581
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/69ac644e3da468cee087b581

Copy link
Copy Markdown
Contributor

@aaronArinder aaronArinder left a comment

Choose a reason for hiding this comment

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

only suggestion is some potentially different wording for the warn!()

Comment thread apollo-router/src/services/external.rs Outdated
output.entry(k).or_insert_with(Vec::new).push(v)
match String::from_utf8(v.as_bytes().to_vec()) {
Ok(v) => output.entry(k).or_insert_with(Vec::new).push(v),
Err(e) => tracing::warn!("unable to externalize header value for {}: {}", k, e),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what does externalize mean? convertible to something... external? wondering if this might confuse folks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, is this better? More direct

Suggested change
Err(e) => tracing::warn!("unable to externalize header value for {}: {}", k, e),
Err(e) => tracing::warn!("unable to convert header value to utf-8 for {}: {}", k, e),

So the full error will look like unable to convert header value to utf-8 for test-header: invalid utf-8 sequence of 1 bytes from index 7

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that lgtm; and, I liked your idea of being explicit too by calling out that it won't be sent to the coprocessor (assuming this codepath only deals with coprocessors, if not, it's probably more effort than it's worth to add a log for just coprocessors)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Pushed a commit that mentions it wont be sent to a coprocessor, currently the external mod is only used by coprocessor logic despite being separate, I think its reasonable that if it is used elsewhere in future then the implementor can change the log text

Copy link
Copy Markdown
Contributor

@pragl pragl left a comment

Choose a reason for hiding this comment

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

I believe the docs change needs to be copied to one other location. Please take a look when you get a chance. Thank you!

Comment thread docs/source/routing/customization/coprocessor.mdx
Copy link
Copy Markdown
Contributor

@pragl pragl left a comment

Choose a reason for hiding this comment

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

LGTM

@rohan-b99 rohan-b99 merged commit 24bb24a into dev Jan 29, 2026
15 checks passed
@rohan-b99 rohan-b99 deleted the rohan-b99/allow-non-utf8-characters-in-headers branch January 29, 2026 15:58
the-gigi-apollo pushed a commit that referenced this pull request Feb 4, 2026
briannafugate408 pushed a commit that referenced this pull request Feb 4, 2026
@abernix abernix mentioned this pull request Feb 24, 2026
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.

3 participants