Skip to content

fix(browser): classify selected web trace file failures by cause - #1396

Merged
kaoru0822-kitauji merged 1 commit into
mainfrom
fix/web-trace-selected-file-failures
Oct 10, 2026
Merged

kaoru0822-kitauji merged 1 commit into
mainfrom
fix/web-trace-selected-file-failures

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

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

trace_web_module_imports and trace_web_source_location reported a missing
or non-file manifest, source map or import map as artifact_operation_failed
("Artifact could not be read or written" / "unsafe or conflicting internal
path"). These are caller selections: report ENOENT/ENOTDIR and non-regular
files as invalid input on the selected field, and EACCES/EPERM as a host
access denial. A missing manifest-derived source file stays an artifact fault.

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

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@kaoru0822-kitauji
kaoru0822-kitauji merged commit 2b6e9ec into main Oct 10, 2026
21 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/web-trace-selected-file-failures branch October 10, 2026 02:29
@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: The fix works on Linux for every bad file I tried. One case got worse. A bad path inside the manifest now blames the caller. Moving one line fixes it.

What I ran

The two changed test files pass on all three Nodes. That is 15 of 15 each time. The nearby web tests pass too, 124 of 124 on Node 24. Your new tests fail on base, so they do pin the change.

Real files through the CLI

I made each bad file for real on disk. Then I ran both trace-web-module-imports and trace-web-source-location. I fed each bad path to the manifest, import map and source map fields. All three Nodes gave the same results.

Bad file base head
missing, missing parent, parent is a file io invalid_request
folder, FIFO, /dev/null, symlink path invalid_request
mode 000, folder mode 000, a path under /root io access_denied
bad JSON, bad UTF-8, empty invalid_request same
missing source under files/ io same

Here io and path mean artifact_operation_failed. So the main cases land where the PR says.

One case moved the wrong way

Say the manifest's relative_path is unsafe. I tried six, like ../outside.js, /etc/hostname and modules/./main.js. Base calls it an artifact fault (path). Head calls it invalid_request on script_index. That tells the caller to fix their input. But the manifest is the problem.

The cause is the order. normalizeArtifactPath throws before callerSelected = false runs. So the new code treats it as a picked file.

I tried a fix. I moved callerSelected = false; up to just after field = ["script_index"];. Then all six unsafe paths went back to path. The 15 tests still pass. Nothing else in my case list changed.

Still in the plain io bucket

These are still io on head. You may want them too.

  • A symlink loop in a parent folder gives ELOOP.
  • A name over 255 bytes gives ENAMETOOLONG.
  • A path over 4096 bytes gives ENAMETOOLONG.

A long path that still fits loads fine. I tried 3873 bytes.

Not run

  • verify:browser and the browser verify scripts. This PR does not touch capture.
  • MCP by hand. I only used the CLI.
  • Root, Windows and macOS.
  • A real read-only mount. I can't make one without root.

Thanks, kaoru0822-kitauji. This is a nice change.

Test setup
  • Box: Nobara 44 Linux, not root
  • Node: 22.23.1, 24.18.0 and 26.11.1
  • Head / base: c398c920 / 7aa4d768
  • Chromium 154.0.8037.57 (BSD-3-Clause) is here, but not needed. This PR only reads local files.

🤖 Generated with Claude Code (Opus 5.5) 🦊

darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…luto#1396)

trace_web_module_imports and trace_web_source_location reported a missing
or non-file manifest, source map or import map as artifact_operation_failed
("Artifact could not be read or written" / "unsafe or conflicting internal
path"). These are caller selections: report ENOENT/ENOTDIR and non-regular
files as invalid input on the selected field, and EACCES/EPERM as a host
access denial. A missing manifest-derived source file stays an artifact fault.
@morluto morluto added the bug Something isn't working label Oct 14, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants