Repository navigation
Conversation
A version-3 map whose sourcesContent array is shorter than its sources inventory was rejected by hasValidSourceMapContents, dropping every original-source declaration during analyze-javascript-application instead of decoding missing trailing slots as null content. 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. Relax the shared validator from exact cardinality 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, so no consumer changes are needed. Fixes morluto#2821
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a208d11c4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| contents === null || | ||
| (Array.isArray(contents) && | ||
| contents.length === sourceCount && | ||
| contents.length <= sourceCount && |
There was a problem hiding this comment.
Update boundary tests for accepted short content arrays
When the Vitest boundary projects run, the new [] <= 1 case is accepted here, but the unchanged cases in tests/boundary/filesystem/javascriptArtifactReconstruction.test.ts:135-169 and tests/boundary/browser/webSourceMapFetcher.test.ts:809-842 feed exactly sources: ["source.ts"] with sourcesContent: [] and still assert an invalid result. Those two parameterized cases now fail, so update them to assert accepted missing content and preserve their malformed-cardinality coverage with an oversized array rather than changing only the module test.
AGENTS.md reference: AGENTS.md:L77-L77
Useful? React with 👍 / 👎.
|
| it("accepts trailing missing content slots as null content per ECMA-426", () => { | ||
| expect(hasValidSourceMapContents(2, ["retained source"])).toBe(true); | ||
| expect(hasValidSourceMapContents(2, [])).toBe(true); | ||
| expect(hasValidSourceMapContents(2, ["a", "b", "extra"])).toBe(false); |
There was a problem hiding this comment.
Restored sources lack test coverage
The new test checks only hasValidSourceMapContents, not the analysis output this fix restores. A future change could drop original-source declarations again while these tests still pass. Add a regression test through analyzeJavaScriptArtifactFiles with two sources and one content entry. Assert that both declarations survive, the first keeps its content, and the second has null content and hash.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/sourceMapContents.test.ts
Line: 12-15
Comment:
**Restored sources lack test coverage**
The new test checks only `hasValidSourceMapContents`, not the analysis output this fix restores. A future change could drop original-source declarations again while these tests still pass. Add a regression test through `analyzeJavaScriptArtifactFiles` with two sources and one content entry. Assert that both declarations survive, the first keeps its content, and the second has null content and hash.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
The source-map cardinality fix is already integrated in #2873 ( Validation for this maintenance update was source and Git tree/ancestry inspection only; no tests or executable checks were run. |
Summary
A version-3 map whose
sourcesContentarray is shorter than itssourcesinventory is rejected byhasValidSourceMapContents, which drops every original-source declaration duringanalyze-javascript-applicationinstead of decoding missing trailing slots as null content. Padding the same array withnullrestores 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 === sourceCounttocontents.length <= sourceCount:Both consumers already read content by source ordinal and map absent entries to null (
JavaScriptArtifactAnalysis.tsviatypeof rawContent === "string",SourceMapFormat.tsvia?? 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.scripts/rea.mjs analyze-javascript-application, short vs padded fixtures):npm run typecheck— clean.npx oxfmt --check+ repo lint gates — clean on the two changed files.