fix(headers): silently skip empty header names instead of throwing#10875
Merged
Conversation
jasonsaayman
requested changes
May 13, 2026
Signed-off-by: Ravi <13908473+rkdfx@users.noreply.github.com>
Signed-off-by: Ravi <13908473+rkdfx@users.noreply.github.com>
8e0546a to
17fadb0
Compare
jasonsaayman
approved these changes
May 22, 2026
4 tasks
jasonsaayman
added a commit
that referenced
this pull request
May 28, 2026
…10875) * fix(headers): silently skip empty header names instead of throwing Signed-off-by: Ravi <13908473+rkdfx@users.noreply.github.com> * chore: add suggested test headers length assert Signed-off-by: Ravi <13908473+rkdfx@users.noreply.github.com> * test(headers): cover whitespace-only header names --------- Signed-off-by: Ravi <13908473+rkdfx@users.noreply.github.com> Co-authored-by: Jay <jasonsaayman@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
AxiosHeaders.setHeaderthrewError: header name must be a non-empty stringwhenever an input source contained an empty key. React Native 0.80+ on Android emits such an entry fromresponse.headers, which made every response throw and crash user code. Switch to a silent skip, mirroringparseHeaders-axios/lib/helpers/parseHeaders.js
Lines 53 to 55 in 847d89b
Linked issue
Closes #6959
Changes
lib/core/AxiosHeaders.js: replace the empty-name throw insetHeaderwith an early return.tests/unit/axiosHeaders.test.js: cover empty-name handling acrossall three input shapes.
Checklist
index.d.tsandindex.d.cts)Summary by cubic
Silently skip empty or whitespace-only header names in
AxiosHeaders.setHeaderto prevent crashes when platforms emit empty keys (e.g., React Native 0.80+ on Android). MirrorsparseHeadersbehavior and fixes #6959.Description
AxiosHeaders.setHeaderwith an early return (no-op).parseHeaders; applies to string keys, plain objects, andMapinputs.Docs
/docs/to note that empty or whitespace-only header names are ignored across string/object/Mapinputs, matchingparseHeaders.Testing
tests/unit/axiosHeaders.test.jscovering empty and whitespace-only names for string, object, andMapinputs.Semantic version impact
Written for commit a63294d. Summary will update on new commits. Review in cubic