Skip to content

fix(javascript): omit self-referential bundler edges with disclosure - #1153

Closed
kaoru0822-kitauji wants to merge 1 commit into
mainfrom
fix/javascript-self-referential-bundler-edges
Closed

kaoru0822-kitauji wants to merge 1 commit into
mainfrom
fix/javascript-self-referential-bundler-edges

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Fixes #1146.

Problem

analyze_javascript_application lost the whole result when a webpack/Rspack chunk referenced itself:

{"code":"unreadable_output","details":{"operation":"analyze_javascript_application","reason":"Result schema rejected 1 issue at /edges/4 (custom)"}}

The application graph schema forbids self-referential edges. #1130 skipped and disclosed them only for module import relationships. Following the new AGENTS.md guidance on adjacent cases, I checked every edge composer. Two more emit self-edges, and both are reproduced on main:

  1. Bundler async chunk (JavaScriptArtifactGraphBundlers.ts). A chunk file that requests one of its own chunk ids resolves to its own chunk node. This covers single-id chunks (push([[1],{…r.e(1)…}])) and merged multi-id chunks (push([[3,4],{…r.e(4)…}])). These are the 8 edges in the issue.
  2. Static reference (JavaScriptArtifactGraphFindings.ts). A bundled module that requires its own key (push([[5],{50(e,t,r){r(50)}}])) resolves back to its own module node.

Other self-reference shapes I checked do not produce self-edges and are unchanged. They resolve to distinct nodes:

Change

  • Both composers skip an edge whose target is its own source, count it, and return the count, as addJavaScriptModuleRelationships does since fix(javascript): omit self-referential import edges with disclosure #1130.
  • graphLimitations discloses each nonzero count through one helper:
    • "N bundler async-chunk request(s) resolved back to the requesting chunk itself and was/were omitted; application graph edges cannot be self-referential."
    • "N static reference(s) resolved back to the referencing module itself …"
  • The self-import message keeps its exact wording.
  • Sibling requests are kept, such as a chunk's request for another chunk id or a module's require of another module.

No schemas change.

Verification

  • New tests/boundary/cli/javascriptSelfReferentialBundlerEdges.test.ts runs through the compiled CLI. It covers single-id and merged self chunk requests (2 omitted, sibling chunk request kept) and a module self-require (1 omitted, sibling require kept). It asserts that no self-edges remain and that the limitations are disclosed. Both tests fail without the source change.
  • All 39 test files that cover the JavaScript artifact graph, bundler registrations or analyze_javascript_application: 275 passed, including javascriptSelfImportRelationships.test.ts.
  • npm run check:fast
  • The one-file reproduction from the issue, the merged-chunk variant and the module self-require each now return a complete result with the disclosure.

I also noticed that async chunk requests resolve only to chunks registered in the same file (chunkLookupKey includes the file path). Cross-file requests stay not-found. That predates this change, which doesn't alter it.

No real Hopper or Ghidra verification was run, because this change does not touch those providers.

🤖 Generated with Claude Code

A webpack/Rspack chunk file that lazily requests one of its own chunk
ids (`__webpack_require__.e(<own id>)`, including merged multi-id
chunks) produced a bundler-async-chunk edge from the chunk to itself. A
bundled module that requires its own key (`r(50)` inside module 50) did
the same through the static-reference composer. The application graph
forbids self-referential edges, so one such edge failed result
validation and lost the entire analysis ("Result schema rejected ...
(custom)").

Apply the treatment #1130 gave self-imports to both composers: skip the
edge, count it, and disclose the omission in the graph limitations. The
shared helper keeps the existing self-import wording.

Fixes #1146

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T01:31:40.733431Z c06444a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #1152, which the maintainer opened a few minutes earlier for #1146. The extra static-reference case (a bundled module requiring its own key) is described on #1152, with a reproduction. I'll send it as a follow-up if it isn't folded in there.

@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks @kaoru0822-kitauji for surfacing how self-referential bundler and static-reference edges could invalidate the whole graph result. Main now omits those edges with explicit limitation counts, preserving the rest of the analysis (main).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] analyze_javascript_application fails result validation when a webpack chunk lazily requests its own chunk id

2 participants