Repository navigation
Conversation
Co-authored-by: GeneralTony007 <[email protected]>
Co-authored-by: GeneralTony007 <[email protected]>
Co-authored-by: GeneralTony007 <[email protected]>
Contributor
[Medium impact] The PR appears safe to merge; no blocking issues were found. SummaryThe Node HTTP adapter now strips a leading BOM for case variants of
Reviews (4) · Last reviewed commit: "test(http): cover UTF-8 BOM aliases and ..." · Reviewed by Greptile |
Author
|
Friendly follow-up on this PR. If you'd like anything changed or added, let me know and I'll update it. |
7 of 8 tasks
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
The HTTP adapter decodes
utf8,utf-8and their case variants with Node's Buffer API, but only strips a leading UTF-8 BOM for the literalutf8spelling. With strict JSON parsing, the other valid spellings reject the same BOM-prefixed response.This makes the BOM check match the UTF-8 aliases in both buffered HTTP responses and data URL text responses.
Linked issue
No separate issue. This is a two-condition consistency fix for an existing encoding option, with a localhost reproduction and failing-before/passing-after coverage. It does not add an encoding or change the API.
Changes
Validation
Linux, fresh dependency installation with Node 22, followed by validation with Node 26.13.1:
npm ci --ignore-scripts: passed with Node 22; no dependency or lockfile changes.npm run lint: passed.npm run build: passed.npm run test:vitest:unit: 78 files, 1,818 tests passed in one run.npm run test:vitest:browser:headless: Chromium, Firefox and WebKit, 84 files, 1,131 tests passed, 3 skipped.lib/adapters/http.jsto the base gives 8 failures and 10 passes.git diff --check: passed.WebKit required additional shared libraries in the local environment. They were extracted into a private directory, and an isolated browser wrapper retained that process-local library path. Launch validation remained enabled; no host packages were installed.
The earlier Node 22 unit run failed an unrelated inherited-Symbol.iterator fetch test, which also fails on the untouched base with that runtime. The complete Node 26 run above passes. An earlier isolated HTTP/2 run needed the suite's existing retry; the final complete unit run passed.
GitHub Actions status for this PR still needs checking after submission; local passes are not a hosted-matrix result.
Compatibility and documentation
Patch-level bug fix for Node's HTTP adapter. No public API, type, export, packaging or build configuration changes, and no intentional breaking change. Non-UTF-8 decoding and binary/stream response bytes are unchanged.
No deferred docs change is needed: the existing responseEncoding option already accepts Node Buffer encodings. This corrects inconsistent handling of those encodings rather than introducing a new option.
index.d.tsandindex.d.ctsneed no changes. Packed module/smoke suites are not applicable to this source-only adapter fix.Checklist
PRE_RELEASE_CHANGELOG.mdentry addedAI-assisted contribution. I cannot apply repository labels through this submission route; a maintainer needs to add
ai-assisted.Summary by cubic
Description
The Node HTTP adapter now strips a leading UTF-8 BOM for all supported UTF-8 encoding spellings (
utf8,utf-8,UTF8,UTF-8) instead of only the literalutf8. Previously, responses decoded with the other aliases kept the BOM, which could break strict JSON parsing and leave a leading\uFEFFin text responses.Reasoning: the
responseEncodingoption already accepts Node Buffer encodings, so all UTF-8 aliases should behave consistently. The change covers both buffered HTTP responses and data URL text responses; non-UTF-8 encodings and binary or stream bytes are unchanged.Additional context: this is a patch-level consistency fix and does not add an encoding or change the public API.
Docs
No documentation change needed. The
responseEncodingoption already supports Node Buffer encodings; no new option is introduced.Testing
Added
tests/unit/adapters/http-bom-encoding.test.jswith 18 cases: strict HTTP JSON parsing and data URL text for the default and five UTF-8 spellings, byte preservation forlatin1,hex,base64, andutf16le, and unchanged BOM bytes inarraybufferandstreamresponses. The 8 cases exercising the aliases fail without the fix. All existing unit and browser suites, lint, and build pass.Semantic version impact
Patch-level bug fix. No public API, type, export, packaging, or build configuration changes, and no intentional breaking behavior.
Written for commit cadb794. Summary will update on new commits.