[GH-ISSUE #1129] [Bug] analyze_javascript_application fails result validation when any module imports itself #402

Closed
opened 2026-10-15 18:24:46 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @BaaRai on GitHub (Oct 8, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/1129

Before submitting

  • Searched related issues and PRs, including #1053, #1055, #1088 and #1101.
  • Removed credentials, private paths and sensitive target data.

Area

MCP or agent integration; JavaScript/Electron application analysis.

Observed behavior

Running analyze_javascript_application against a real-world monorepo (a TypeScript-heavy packages directory) fails after a complete analysis:

{
  "error": "JavaScript application analysis failed",
  "code": "unreadable_output",
  "message": "Analysis returned an unreadable result. Retry once; if it continues, run `rea doctor`.",
  "details": {
    "operation": "analyze_javascript_application",
    "reason": "Result schema rejected 22 issues at /edges/1537 (custom)"
  }
}

Every rejected issue is the graph invariant Application graph edges cannot be self-referential. The relationship composer adds an imports edge whenever a specifier resolves, without checking whether the resolved target is the importing module itself, so ordinary self-imports fail result validation for the whole analysis. Reproduced shapes in the wild:

  • a literal self-import (import "./a.js" inside a.js, package self-references),
  • a CommonJS self-require (require("./c.cjs") inside c.cjs),
  • a TypeScript extension rewrite landing on the source file (import "./util.js" inside util.ts).

On the test target the analyzer recovered 92,000+ edges and 22 of them were self-referential; one such specifier is enough to lose the entire result.

Reproduction

  1. Create a directory with a.js containing import "./a.js"; and b.js containing import { value } from "./a.js";.
  2. npx rea-agents analyze-javascript-application <dir> --json
  3. Observe unreadable_output with Result schema rejected 1 issue ... (custom).

Expected behavior

Self-imports are real observations, but an edge from a module to itself carries no module-graph information and the schema invariant is deliberate. The composer should omit self-referential import edges and disclose the omission in the graph limitations, so the rest of the analysis survives and the fact stays visible.

Impact and scope

Any JavaScript/Electron target with at least one self-importming module cannot be analyzed at all through this operation. This includes common published-package patterns, so real Electron app directories are affected, not hand-crafted fixtures.

Analysis or suspected cause

addImportRelationship in src/application/javascript/JavaScriptModuleRelationships.ts adds the edge unconditionally; the fix belongs at composition time (skip and disclose), not in the schema.

Willing to submit a PR

Yes, follow-up PR in a moment.

Originally created by @BaaRai on GitHub (Oct 8, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/1129 ### Before submitting - [x] Searched related issues and PRs, including #1053, #1055, #1088 and #1101. - [x] Removed credentials, private paths and sensitive target data. ### Area MCP or agent integration; JavaScript/Electron application analysis. ### Observed behavior Running `analyze_javascript_application` against a real-world monorepo (a TypeScript-heavy packages directory) fails after a complete analysis: ```json { "error": "JavaScript application analysis failed", "code": "unreadable_output", "message": "Analysis returned an unreadable result. Retry once; if it continues, run `rea doctor`.", "details": { "operation": "analyze_javascript_application", "reason": "Result schema rejected 22 issues at /edges/1537 (custom)" } } ``` Every rejected issue is the graph invariant `Application graph edges cannot be self-referential`. The relationship composer adds an `imports` edge whenever a specifier resolves, without checking whether the resolved target is the importing module itself, so ordinary self-imports fail result validation for the whole analysis. Reproduced shapes in the wild: - a literal self-import (`import "./a.js"` inside `a.js`, package self-references), - a CommonJS self-require (`require("./c.cjs")` inside `c.cjs`), - a TypeScript extension rewrite landing on the source file (`import "./util.js"` inside `util.ts`). On the test target the analyzer recovered 92,000+ edges and 22 of them were self-referential; one such specifier is enough to lose the entire result. ### Reproduction 1. Create a directory with `a.js` containing `import "./a.js";` and `b.js` containing `import { value } from "./a.js";`. 2. `npx rea-agents analyze-javascript-application <dir> --json` 3. Observe `unreadable_output` with `Result schema rejected 1 issue ... (custom)`. ### Expected behavior Self-imports are real observations, but an edge from a module to itself carries no module-graph information and the schema invariant is deliberate. The composer should omit self-referential import edges and disclose the omission in the graph limitations, so the rest of the analysis survives and the fact stays visible. ### Impact and scope Any JavaScript/Electron target with at least one self-importming module cannot be analyzed at all through this operation. This includes common published-package patterns, so real Electron app directories are affected, not hand-crafted fixtures. ### Analysis or suspected cause `addImportRelationship` in `src/application/javascript/JavaScriptModuleRelationships.ts` adds the edge unconditionally; the fix belongs at composition time (skip and disclose), not in the schema. ### Willing to submit a PR Yes, follow-up PR in a moment.
bsakaguchi 2026-10-15 18:24:46 +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#402
No description provided.