GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(headers): silently skip empty header names instead of throwing by rkdfx · Pull Request #10875 · axios/axios

Conversation

@rkdfx

@rkdfx rkdfx commented May 10, 2026 •
edited by cubic-dev-ai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

AxiosHeaders.setHeader threw Error: header name must be a non-empty string whenever an input source contained an empty key. React Native 0.80+ on Android emits such an entry from response.headers, which made every response throw and crash user code. Switch to a silent skip, mirroring parseHeaders -

axios/lib/helpers/parseHeaders.js

Lines 53 to 55 in 847d89b

if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
return;
}

Linked issue

Closes #6959

Changes

  • lib/core/AxiosHeaders.js: replace the empty-name throw in
    setHeader with an early return.
  • tests/unit/axiosHeaders.test.js: cover empty-name handling across
    all three input shapes.

Checklist

  • Tests added or updated (or N/A with reason)
  • Docs / types updated if public API changed (index.d.ts and index.d.cts)
  • No breaking changes (or called out explicitly above)

Summary by cubic

Silently skip empty or whitespace-only header names in AxiosHeaders.setHeader to prevent crashes when platforms emit empty keys (e.g., React Native 0.80+ on Android). Mirrors parseHeaders behavior and fixes #6959.

Description

  • Summary of changes: Replace the throw on empty/whitespace-only header names in AxiosHeaders.setHeader with an early return (no-op).
  • Reasoning: React Native Android can emit an empty-name header, which previously caused responses to throw and crash user code.
  • Additional context: Matches parseHeaders; applies to string keys, plain objects, and Map inputs.

Docs

  • Update /docs/ to note that empty or whitespace-only header names are ignored across string/object/Map inputs, matching parseHeaders.

Testing

  • Added unit tests in tests/unit/axiosHeaders.test.js covering empty and whitespace-only names for string, object, and Map inputs.
  • Asserts no throws, valid headers remain, and object length is 2.

Semantic version impact

  • Patch: bug fix with no API changes; removes unexpected throws without breaking valid usage.

Written for commit a63294d. Summary will update on new commits. Review in cubic

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rkdfx
rkdfx requested a review from jasonsaayman as a code owner May 10, 2026 06:57
cubic-dev-ai[bot]
cubic-dev-ai Bot reviewed May 10, 2026
View reviewed changes

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jasonsaayman
jasonsaayman requested changes May 13, 2026
View reviewed changes

@jasonsaayman jasonsaayman left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Two small suggestions are inline; both are non-blocking on their own but flag together. Nice fix overall: leaf-level placement is the right call, and the test matrix across string/object/Map is exactly what this needs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/core/AxiosHeaders.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/axiosHeaders.test.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jasonsaayman jasonsaayman assigned rkdfx May 13, 2026
@jasonsaayman jasonsaayman added priority::medium labels May 13, 2026
joe345-str
joe345-str approved these changes May 14, 2026
View reviewed changes

@joe345-str joe345-str left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

merge please

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rkdfx reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@rkdfx
rkdfx requested a review from jasonsaayman May 15, 2026 20:04
rkdfx added 2 commits May 20, 2026 21:21
@rkdfx
fix(headers): silently skip empty header names instead of throwing
ee8713d
Signed-off-by: Ravi <[email protected]>
@rkdfx
chore: add suggested test headers length assert
17fadb0
Signed-off-by: Ravi <[email protected]>
@rkdfx
rkdfx force-pushed the fix/6959-empty-header-name-skip branch from 8e0546a to 17fadb0 Compare May 20, 2026 15:51
jasonsaayman added 2 commits May 22, 2026 20:19
@jasonsaayman
Merge branch 'v1.x' into fix/6959-empty-header-name-skip
9ceeec4
@jasonsaayman
test(headers): cover whitespace-only header names
a63294d
jasonsaayman
jasonsaayman approved these changes May 22, 2026
View reviewed changes
@jasonsaayman
jasonsaayman merged commit 278041d into axios:v1.x May 22, 2026
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@jasonsaayman jasonsaayman mentioned this pull request May 27, 2026
fix(headers): tolerate whitespace-only string from getAllResponseHeaders() #10932
Closed
4 tasks done
jasonsaayman added a commit that referenced this pull request May 28, 2026
@rkdfx @jasonsaayman
fix(headers): silently skip empty header names instead of throwing (#…
93d866e
…10875)

* fix(headers): silently skip empty header names instead of throwing

Signed-off-by: Ravi <[email protected]>

* chore: add suggested test headers length assert

Signed-off-by: Ravi <[email protected]>

* test(headers): cover whitespace-only header names

---------

Signed-off-by: Ravi <[email protected]>
Co-authored-by: Jay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cubic-dev-ai cubic-dev-ai[bot] cubic-dev-ai[bot] left review comments
@jasonsaayman jasonsaayman jasonsaayman approved these changes
+1 more reviewer
@joe345-str joe345-str joe345-str approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@rkdfx rkdfx

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[React Native 0.80.1] Header name must be a non-empty string on Android

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@rkdfx @jasonsaayman @joe345-str
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.