Skip to content

fix(artifacts): report which path constraint failed - #847

Merged
morluto merged 1 commit into
mainfrom
fix/artifact-failure-detail
Oct 7, 2026
Merged

morluto merged 1 commit into
mainfrom
fix/artifact-failure-detail

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Summary

When an archive fails REA's path-safety checks, the caller-visible error says to inspect a path that it never reports:

{
  "code": "artifact_operation_failed",
  "message": "Artifact contains an unsafe or conflicting internal path. Inspect the reported path and correct the artifact before retrying.",
  "details": { "operation": "analyze_javascript_application", "reason": "path" }
}

The specific failure, for example Artifact path collision: a.js, exists as the ArtifactReaderFailure message. However, ArtifactProvider.translateFailure and JavaScriptApplicationService drop it when they build the ArtifactOperationError. With 87 throw sites, the reason alone (path, format, limit, …) can't tell an analyst which entry or constraint failed. AGENTS.md: "Diagnostics should identify the failed constraint and the target… generic catches must not erase actionable validation details."

Real archives can trigger this. Case-fold collisions such as Main.js + main.js are legal in ZIP/ASAR files built on case-sensitive filesystems, and REA deliberately rejects them (fail-closed). This PR leaves that policy unchanged; it only makes the rejection explain itself.

Fix

  • ArtifactOperationError gets an optional detail, which both conversion sites fill from ArtifactReaderFailure.message. The error projection emits it as details.detail. export_web_scripts already preserved its message this way.
  • The path messages now identify the target:
    • Case-fold collision: Artifact path collision: main.js differs only in case from Main.js (both spellings).
    • Artifact path is absolute or unsafe: "a\\b.js" and Artifact path is not normalized: "../escape". The input is JSON-escaped because such names can contain NUL or control characters.

After the change:

"details": { "operation": "analyze_javascript_application", "reason": "path",
             "detail": "Artifact path collision: a.js differs only in case from A.js" }

Contract / behavior changes

  • artifact_operation_failed errors gain an optional details.detail string. The published error contract already defines that variant's details as an open record, so docs:check passes with no regeneration.
  • The integrity-mismatch variant, which has strict details, is unchanged.
  • Three internal failure messages are more specific; the one existing test asserting them is updated.

Verification

  • New tests/boundary/providers/native/artifactProvider.failureDetail.test.ts uses real ZIPs (Main.js + main.js, and a\b.js) through the public ArtifactProvider and projectAnalysisError. Both cases fail on main and pass here.
  • Built CLI: analyze-javascript-application and inspect-artifact on crafted ASARs (case collision, backslash, NUL, and / in a name) now report a detail for each.
  • All artifact-provider, filesystem, artifact MCP, and CLI-output boundary suites: 66 files / 405 tests passed (1 skipped).
  • npm run check:changed (33 files / 333 tests), npm run check:fast, and npm run docs:check passed.

No Hopper/Ghidra/IDA involvement.

🤖 Generated with Claude Code

Artifact path failures told callers to "inspect the reported path" but
reported none: `ArtifactReaderFailure` messages such as
`Artifact path collision: ...` were dropped when converted to
`ArtifactOperationError`, leaving only `{ operation, reason: "path" }`.

Carry the failure message into `details.detail` for artifact tools and
JavaScript application analysis. Name both spellings in case-fold
collisions and include the JSON-escaped input in unsafe and
non-normalized path messages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 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-07T04:11:50.730942Z 3a9738a 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.

@morluto
morluto merged commit 3f1a77f into main Oct 7, 2026
19 checks passed
@morluto
morluto deleted the fix/artifact-failure-detail branch October 7, 2026 04:17
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
Artifact path failures told callers to "inspect the reported path" but
reported none: `ArtifactReaderFailure` messages such as
`Artifact path collision: ...` were dropped when converted to
`ArtifactOperationError`, leaving only `{ operation, reason: "path" }`.

Carry the failure message into `details.detail` for artifact tools and
JavaScript application analysis. Name both spellings in case-fold
collisions and include the JSON-escaped input in unsafe and
non-normalized path messages.
@morluto morluto added bug Something isn't working area: evidence Evidence, artifacts, and reconstruction labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants