[PR #1396] [MERGED] fix(browser): classify selected web trace file failures by cause #2853

Closed
opened 2026-10-17 21:11:02 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1396
Author: @kaoru0822-kitauji
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/web-trace-selected-file-failures


📝 Commits (1)

  • c398c92 fix(browser): classify selected web trace file failures by cause

📊 Changes

6 files changed (+138 additions, -18 deletions)

View changed files

📝 src/browser/assets/LocalWebScriptArtifacts.ts (+3 -1)
📝 src/browser/assets/WebArtifactReads.ts (+37 -0)
📝 src/browser/assets/WebSourceLocationArtifacts.ts (+1 -0)
📝 src/browser/modules/WebModuleArtifacts.ts (+1 -0)
📝 tests/boundary/filesystem/webModuleArtifacts.test.ts (+83 -9)
📝 tests/boundary/filesystem/webSourceLocationArtifacts.test.ts (+13 -8)

📄 Description

Problem

trace_web_module_imports and trace_web_source_location (CLI trace-web-module-imports / trace-web-source-location) report a bad caller-selected file as an artifact read/write fault:

Selected file main result (CLI and MCP)
manifest_path missing artifact_operation_failed / io: "Artifact could not be read or written. Check file access and try again." (ENOENT only in details.detail)
manifest_path is a directory artifact_operation_failed / path: "Artifact contains an unsafe or conflicting internal path. Inspect the reported path and correct the artifact before retrying."
source_map.path / import_map.path missing same io failure
any of them unreadable (mode 000) same io failure (EACCES)

The advice sends the caller to repair an artifact when the selection is wrong. The sibling tools already separate these cases: inspect_web_network_capture (src/browser/history/CaptureFailures.ts) and export_web_scripts (#1240) report invalid_request with an issue on the selected field, and access_denied for a host permission denial.

Change

WebArtifactReadContext now records whether the caller named the file (callerSelected). For a caller-selected manifest, source map or import map:

Read failure Result
ENOENT, ENOTDIR invalid_request; invalid_value issue on the selected field: "Selected file could not be read (ENOENT): "
not a regular file / symlink (ArtifactReaderFailure path) invalid_request; invalid_value issue: "Expected a regular file without a symlink: "
EACCES, EPERM access_denied with path and system_code

These stay unchanged: malformed JSON or UTF-8 (invalid_format), the byte limit, changes during the read, cancellation, and every failure on the manifest-derived source file under files/ (still an artifact fault, because the export is incomplete or tampered). Schemas are unchanged.

Tests

tests/boundary/filesystem/webModuleArtifacts.test.ts, new caller-selected web module files block:

  • a missing manifest, a manifest under a missing parent, and a directory → invalid_request on manifest_path;
  • an unreadable manifest → access_denied (skipped on Windows and as root);
  • a missing import map → invalid_request on import_map.path;
  • a missing manifest-derived source → still ArtifactOperationError / io.

It replaces the test that pinned a missing manifest as ArtifactOperationError/io. In webSourceLocationArtifacts.test.ts, a missing source map is now expected as invalid_request on source_map.path.

Verification:

  • npm run test:focused -- tests/acceptance/webModuleCli.test.ts plus all webModule*/webSource* boundary and MCP tests (10 files, 103 passed)
  • npm run check:changed, npm run format:check, jscpd 2.46% (< 2.5%)
  • Real CLI from dist: a missing manifest and a directory each return the invalid_request issue shown above.

No Hopper/Ghidra or browser verification needed (local file reads only).

🤖 Generated with Claude Code


🔄 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/1396 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/web-trace-selected-file-failures` --- ### 📝 Commits (1) - [`c398c92`](https://github.com/morluto/rea/commit/c398c920c70dcfaa02176af1b4274a3942320a5f) fix(browser): classify selected web trace file failures by cause ### 📊 Changes **6 files changed** (+138 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/assets/LocalWebScriptArtifacts.ts` (+3 -1) 📝 `src/browser/assets/WebArtifactReads.ts` (+37 -0) 📝 `src/browser/assets/WebSourceLocationArtifacts.ts` (+1 -0) 📝 `src/browser/modules/WebModuleArtifacts.ts` (+1 -0) 📝 `tests/boundary/filesystem/webModuleArtifacts.test.ts` (+83 -9) 📝 `tests/boundary/filesystem/webSourceLocationArtifacts.test.ts` (+13 -8) </details> ### 📄 Description ## Problem `trace_web_module_imports` and `trace_web_source_location` (CLI `trace-web-module-imports` / `trace-web-source-location`) report a bad **caller-selected** file as an artifact read/write fault: | Selected file | `main` result (CLI and MCP) | | --- | --- | | `manifest_path` missing | `artifact_operation_failed` / `io`: "Artifact could not be read or written. Check file access and try again." (`ENOENT` only in `details.detail`) | | `manifest_path` is a directory | `artifact_operation_failed` / `path`: "Artifact contains an unsafe or conflicting internal path. Inspect the reported path and correct the artifact before retrying." | | `source_map.path` / `import_map.path` missing | same `io` failure | | any of them unreadable (mode 000) | same `io` failure (`EACCES`) | The advice sends the caller to repair an artifact when the selection is wrong. The sibling tools already separate these cases: `inspect_web_network_capture` (`src/browser/history/CaptureFailures.ts`) and `export_web_scripts` (#1240) report `invalid_request` with an issue on the selected field, and `access_denied` for a host permission denial. ## Change `WebArtifactReadContext` now records whether the caller named the file (`callerSelected`). For a caller-selected manifest, source map or import map: | Read failure | Result | | --- | --- | | `ENOENT`, `ENOTDIR` | `invalid_request`; `invalid_value` issue on the selected field: "Selected file could not be read (ENOENT): <path>" | | not a regular file / symlink (`ArtifactReaderFailure` `path`) | `invalid_request`; `invalid_value` issue: "Expected a regular file without a symlink: <path>" | | `EACCES`, `EPERM` | `access_denied` with `path` and `system_code` | These stay unchanged: malformed JSON or UTF-8 (`invalid_format`), the byte limit, changes during the read, cancellation, and every failure on the **manifest-derived** source file under `files/` (still an artifact fault, because the export is incomplete or tampered). Schemas are unchanged. ## Tests `tests/boundary/filesystem/webModuleArtifacts.test.ts`, new `caller-selected web module files` block: - a missing manifest, a manifest under a missing parent, and a directory → `invalid_request` on `manifest_path`; - an unreadable manifest → `access_denied` (skipped on Windows and as root); - a missing import map → `invalid_request` on `import_map.path`; - a missing manifest-derived source → still `ArtifactOperationError` / `io`. It replaces the test that pinned a missing manifest as `ArtifactOperationError`/`io`. In `webSourceLocationArtifacts.test.ts`, a missing source map is now expected as `invalid_request` on `source_map.path`. Verification: - `npm run test:focused -- tests/acceptance/webModuleCli.test.ts` plus all `webModule*`/`webSource*` boundary and MCP tests (10 files, 103 passed) - `npm run check:changed`, `npm run format:check`, jscpd 2.46% (< 2.5%) - Real CLI from `dist`: a missing manifest and a directory each return the `invalid_request` issue shown above. No Hopper/Ghidra or browser verification needed (local file reads only). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:11:02 +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#2853
No description provided.