[PR #2869] [CLOSED] fix(source-maps): accept short sourcesContent arrays as missing slots #5454

Closed
opened 2026-10-31 01:06:45 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2869
Author: @Jackzigen
Created: 10/13/2026
Status: ❌ Closed

Base: main ← Head: fix/source-map-short-sources-content


📝 Commits (2)

  • 3a208d1 fix(source-maps): accept short sourcesContent arrays as missing slots
  • 9e249ca chore: merge main into PR #2869

📄 Description

Summary

A version-3 map whose sourcesContent array is shorter than its sources inventory is rejected by hasValidSourceMapContents, which drops every original-source declaration during analyze-javascript-application instead of decoding missing trailing slots as null content. Padding the same array with null restores all sources, so the cardinality gate is stricter than the decoding algorithm.

Per ECMA-426 DecodeSourceMapSources step 6.5, a content entry is read only when the source index is within sourcesContent; the decoded source then starts with null content. The algorithm iterates the source inventory, so decoding never depends on exact cardinality.

This relaxes the shared validator from contents.length === sourceCount to contents.length <= sourceCount:

  • trailing missing slots validate and decode as null content, matching the padded-array behavior;
  • scalar content fields and non-string/non-null entries are still rejected;
  • extra entries beyond the source inventory are still rejected, since decoding ignores them silently and that signals a mismatched map.

Both consumers already read content by source ordinal and map absent entries to null (JavaScriptArtifactAnalysis.ts via typeof rawContent === "string", SourceMapFormat.ts via ?? null), so no consumer changes are needed.

Fixes #2821

Verification

  • npx vitest run src/domain/sourceMapContents.test.ts — 2 tests (added the short/empty/extra boundary cases, flipped the short-array expectation per ECMA-426).
  • npx vitest run src/application/javascript/JavaScriptArtifactAnalysis.sourceMaps.test.ts src/javascript/sourceMaps/TraceSourceMap.test.ts — 26 passed, no regressions at either consumer.
  • Issue reproduction on the built CLI (scripts/rea.mjs analyze-javascript-application, short vs padded fixtures):
{ name: 'short', coverage: 'partial' -> 'complete', originals: 0 -> 2 }
{ name: 'padded', coverage: 'complete', originals: 2 }  // unchanged
  • npm run typecheck — clean.
  • npx oxfmt --check + repo lint gates — clean on the two changed files.

🔄 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/2869 **Author:** [@Jackzigen](https://github.com/Jackzigen) **Created:** 10/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/source-map-short-sources-content` --- ### 📝 Commits (2) - [`3a208d1`](https://github.com/morluto/rea/commit/3a208d11c4b16a38574d6bd136933f612e07fe83) fix(source-maps): accept short sourcesContent arrays as missing slots - [`9e249ca`](https://github.com/morluto/rea/commit/9e249cae0398ca39fee223c29eef9bd56b97e6db) chore: merge main into PR #2869 ### 📄 Description ## Summary A version-3 map whose `sourcesContent` array is shorter than its `sources` inventory is rejected by `hasValidSourceMapContents`, which drops **every** original-source declaration during `analyze-javascript-application` instead of decoding missing trailing slots as null content. Padding the same array with `null` restores all sources, so the cardinality gate is stricter than the decoding algorithm. Per ECMA-426 [DecodeSourceMapSources](https://tc39.es/ecma426/#sec-decodesourcemapsources) step 6.5, a content entry is read only when the source index is within `sourcesContent`; the decoded source then starts with null content. The algorithm iterates the source inventory, so decoding never depends on exact cardinality. This relaxes the shared validator from `contents.length === sourceCount` to `contents.length <= sourceCount`: - trailing missing slots validate and decode as null content, matching the padded-array behavior; - scalar content fields and non-string/non-null entries are still rejected; - extra entries beyond the source inventory are still rejected, since decoding ignores them silently and that signals a mismatched map. Both consumers already read content by source ordinal and map absent entries to null (`JavaScriptArtifactAnalysis.ts` via `typeof rawContent === "string"`, `SourceMapFormat.ts` via `?? null`), so no consumer changes are needed. Fixes #2821 ## Verification - `npx vitest run src/domain/sourceMapContents.test.ts` — 2 tests (added the short/empty/extra boundary cases, flipped the short-array expectation per ECMA-426). - `npx vitest run src/application/javascript/JavaScriptArtifactAnalysis.sourceMaps.test.ts src/javascript/sourceMaps/TraceSourceMap.test.ts` — 26 passed, no regressions at either consumer. - Issue reproduction on the built CLI (`scripts/rea.mjs analyze-javascript-application`, short vs padded fixtures): ```text { name: 'short', coverage: 'partial' -> 'complete', originals: 0 -> 2 } { name: 'padded', coverage: 'complete', originals: 2 } // unchanged ``` - `npm run typecheck` — clean. - `npx oxfmt --check` + repo lint gates — clean on the two changed files. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:06:45 +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#5454
No description provided.