[PR #1642] [CLOSED] fix(browser): decode prefixed source-map responses #4719

Closed
opened 2026-10-31 00:54:19 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1642
Author: @evenafterallisaid
Created: 10/10/2026
Status: ❌ Closed

Base: main ← Head: fix/source-map-xssi-prefix


📝 Commits (1)

  • 2725e86 fix(browser): decode prefixed source-map responses

📊 Changes

4 files changed (+107 additions, -5 deletions)

View changed files

📝 src/browser/WebSourceMapFetcher.ts (+2 -1)
📝 src/javascript/sourceMaps/SourceMapFormat.ts (+9 -4)
📝 src/javascript/sourceMaps/TraceSourceMap.test.ts (+8 -0)
📝 tests/boundary/browser/webSourceMapFetcher.test.ts (+88 -0)

📄 Description

summary

browser source-map collection now accepts the standard )]}' transport prefix while preserving the fetched response text and digest as evidence. point tracing also accepts a prefix line ending in a carriage return.

problem and expected behavior

an approved HTTP server can return )]}' followed by a line terminator and a valid version 3 map. collection previously marked that response invalid, discarding its mappings and original sources, although ECMA-426 FetchSourceMap defines this transport prefix. the existing point-trace decoder handled LF but rejected CR.

no issue is linked because this was found with a new loopback reproduction; existing issues and prs were checked for overlap.

change and scope

reuse one source-map text normalizer in SourceMapFormat.ts for both parsing paths. it removes the optional BOM and prefix line from the parsing view, accepting LF, CRLF, and CR. browser artifact text, response-byte accounting, hashes, source resolution, and mapping budgets continue to use their existing representations.

contract and boundary impact

  • semantic owner and earliest changed stage: source-map text normalization before JSON parsing.
  • CLI and MCP/tool-catalog contract: no schema changes; supported maps now yield mappings instead of invalid.
  • provider, bridge, target-format, or platform compatibility: HTTP source-map collection and the existing point decoder; no provider protocol changes.
  • evidence, artifact, provenance, or reconstruction contract: original fetched text, bytes, digest, and declared URL remain available.
  • process execution, authorization, cleanup, or containment impact: none; exact-origin approval and fetch limits remain in force.
  • generated metadata, package, or installation impact: none.

evidence and regression coverage

  • tests added: a real loopback HTTP boundary checks plain JSON, LF/CRLF/CR prefixes, mappings, module edges, original artifact text and SHA-256; malformed JSON and a prefix without a line terminator remain invalid. a point-trace regression covers CR.

  • base reproduction: both new regressions fail before the production edits; prefixed HTTP responses are invalid, and CR point tracing throws a JSON syntax error.

  • representative output: a valid prefixed map now has status: "included", a mapping to src/main.ts, and the response prefix still present in artifact.text.

  • remaining proof gaps: no local live Chrome session was run; local tests cross the production HTTP fetch boundary with an actual server. ci's real-browser and real-web-source-map lanes passed on this pr's head.

  • observed, derived, and inferred claims remain distinguishable.

  • artifact identity, source provenance, and failed attempts remain preserved.

  • unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

validation performed

  • node node_modules/vitest/vitest.mjs run src/javascript/sourceMaps/TraceSourceMap.test.ts tests/boundary/browser/webSourceMapFetcher.test.ts -t 'retains prefixed|transport prefix ending' before the fix — both new regressions failed.
  • npm run test:focused -- src/javascript/sourceMaps/TraceSourceMap.test.ts tests/boundary/browser/webSourceMapFetcher.test.ts tests/boundary/browser/webSourceMapHttpStatus.test.ts tests/boundary/browser/webSourceMapNestedCoordinates.test.ts tests/boundary/browser/webSourceMapResponseCleanup.test.ts — 109 tests passed across five files.
  • npm run check — passed, including typecheck, lint, formatting, module boundaries, metadata, knip, and architecture guards; 637 lint warnings, zero errors.
  • npm run verify:test-discovery — all 774 test files discovered exactly once.
  • git diff --check — passed.
  • ci real-browser and real-web-source-map lanes — passed on 2725e860. shard 4 failed in the existing deep-return test, whose embedded child script missed the caller-owned artifact scope migration from newer main commit ffe0574; the missing migration is addressed separately in #1644. the other three shards passed, and the coverage aggregation failure follows from shard 4.

compatibility, safety, and release

  • breaking changes or migration steps: none.
  • real Hopper/Ghidra, browser, or OS coverage: local pinned Node 24.18.0 and npm 11.16.0 on Windows with real HTTP fetching. ci's real-browser and real-web-source-map lanes passed; no local live Chrome session or real Hopper/Ghidra run.
  • package or release metadata impact: none.
  • security, privacy, process, or containment review: normalization applies only to parsing; origin admission, credentials omission, deadlines, byte limits, and original evidence are retained.

review checklist

  • this pr addresses a concrete problem.
  • the pr has one focused outcome and a conventional title.
  • the reason for not linking an issue is stated above.
  • tests cover changed observable behavior and meaningful failures.
  • no docs, contracts, or generated metadata require changes.
  • representative output is included above.
  • the final diff was checked for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1642 **Author:** [@evenafterallisaid](https://github.com/evenafterallisaid) **Created:** 10/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/source-map-xssi-prefix` --- ### 📝 Commits (1) - [`2725e86`](https://github.com/morluto/rea/commit/2725e860625cbe1d68db3c888f6d46329894ae3d) fix(browser): decode prefixed source-map responses ### 📊 Changes **4 files changed** (+107 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/WebSourceMapFetcher.ts` (+2 -1) 📝 `src/javascript/sourceMaps/SourceMapFormat.ts` (+9 -4) 📝 `src/javascript/sourceMaps/TraceSourceMap.test.ts` (+8 -0) 📝 `tests/boundary/browser/webSourceMapFetcher.test.ts` (+88 -0) </details> ### 📄 Description ## summary browser source-map collection now accepts the standard `)]}'` transport prefix while preserving the fetched response text and digest as evidence. point tracing also accepts a prefix line ending in a carriage return. ## problem and expected behavior an approved HTTP server can return `)]}'` followed by a line terminator and a valid version 3 map. collection previously marked that response `invalid`, discarding its mappings and original sources, although [ECMA-426 FetchSourceMap](https://tc39.es/ecma426/#sec-fetchsourcemap) defines this transport prefix. the existing point-trace decoder handled LF but rejected CR. no issue is linked because this was found with a new loopback reproduction; existing issues and prs were checked for overlap. ## change and scope reuse one source-map text normalizer in `SourceMapFormat.ts` for both parsing paths. it removes the optional BOM and prefix line from the parsing view, accepting LF, CRLF, and CR. browser artifact text, response-byte accounting, hashes, source resolution, and mapping budgets continue to use their existing representations. ## contract and boundary impact - semantic owner and earliest changed stage: source-map text normalization before JSON parsing. - CLI and MCP/tool-catalog contract: no schema changes; supported maps now yield mappings instead of `invalid`. - provider, bridge, target-format, or platform compatibility: HTTP source-map collection and the existing point decoder; no provider protocol changes. - evidence, artifact, provenance, or reconstruction contract: original fetched text, bytes, digest, and declared URL remain available. - process execution, authorization, cleanup, or containment impact: none; exact-origin approval and fetch limits remain in force. - generated metadata, package, or installation impact: none. ## evidence and regression coverage - tests added: a real loopback HTTP boundary checks plain JSON, LF/CRLF/CR prefixes, mappings, module edges, original artifact text and SHA-256; malformed JSON and a prefix without a line terminator remain invalid. a point-trace regression covers CR. - base reproduction: both new regressions fail before the production edits; prefixed HTTP responses are `invalid`, and CR point tracing throws a JSON syntax error. - representative output: a valid prefixed map now has `status: "included"`, a mapping to `src/main.ts`, and the response prefix still present in `artifact.text`. - remaining proof gaps: no local live Chrome session was run; local tests cross the production HTTP fetch boundary with an actual server. ci's real-browser and real-web-source-map lanes passed on this pr's head. - [x] observed, derived, and inferred claims remain distinguishable. - [x] artifact identity, source provenance, and failed attempts remain preserved. - [x] unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## validation performed - `node node_modules/vitest/vitest.mjs run src/javascript/sourceMaps/TraceSourceMap.test.ts tests/boundary/browser/webSourceMapFetcher.test.ts -t 'retains prefixed|transport prefix ending'` before the fix — both new regressions failed. - `npm run test:focused -- src/javascript/sourceMaps/TraceSourceMap.test.ts tests/boundary/browser/webSourceMapFetcher.test.ts tests/boundary/browser/webSourceMapHttpStatus.test.ts tests/boundary/browser/webSourceMapNestedCoordinates.test.ts tests/boundary/browser/webSourceMapResponseCleanup.test.ts` — 109 tests passed across five files. - `npm run check` — passed, including typecheck, lint, formatting, module boundaries, metadata, knip, and architecture guards; 637 lint warnings, zero errors. - `npm run verify:test-discovery` — all 774 test files discovered exactly once. - `git diff --check` — passed. - [ci real-browser and real-web-source-map lanes](https://github.com/morluto/rea/actions/runs/38084923695) — passed on `2725e860`. shard 4 failed in the existing deep-return test, whose embedded child script missed the caller-owned artifact scope migration from newer main commit `ffe0574`; the missing migration is addressed separately in [#1644](https://github.com/morluto/rea/pull/1644). the other three shards passed, and the coverage aggregation failure follows from shard 4. ## compatibility, safety, and release - breaking changes or migration steps: none. - real Hopper/Ghidra, browser, or OS coverage: local pinned Node 24.18.0 and npm 11.16.0 on Windows with real HTTP fetching. ci's real-browser and real-web-source-map lanes passed; no local live Chrome session or real Hopper/Ghidra run. - package or release metadata impact: none. - security, privacy, process, or containment review: normalization applies only to parsing; origin admission, credentials omission, deadlines, byte limits, and original evidence are retained. ## review checklist - [x] this pr addresses a concrete problem. - [x] the pr has one focused outcome and a conventional title. - [x] the reason for not linking an issue is stated above. - [x] tests cover changed observable behavior and meaningful failures. - [x] no docs, contracts, or generated metadata require changes. - [x] representative output is included above. - [x] the final diff was checked for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:54:19 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4719
No description provided.