Repository navigation
fix(cli): keep file URLs out of operator-relative path resolution - #2882
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
CLI path normalization resolved every nonblank selected string against the working directory, so executable_path "file:///opt/electron" became an invented local path and failed with ENOENT for that location instead of the field's local-path requirement. Leave `file:` and `scheme://` references unchanged so the shared schema rejects them as non-local paths. One-letter prefixes stay paths, so Windows drive paths and relative names containing a colon resolve as before. Fixes morluto#2577 Co-Authored-By: Claude Opus 5.5 <[email protected]>
d10ba1d to
c270092
Compare
|
Thank you, @shubhamahuja9999, for fixing the Electron path handling in #2882. Keeping file URLs out of working-directory resolution means callers now get the right local-path validation error instead of an ENOENT for a fabricated path, while Windows drive paths remain covered. |
Summary
Fixes #2577
CLI path normalization (
resolveCliJsonPaths) resolved every nonblank selected string against the operator's working directory. A file URL in an Electron path field, such asexecutable_path: "file:///opt/electron", became an invented local path (<cwd>/file:/opt/electron, or<cwd>\file:\opt\electronon Windows). The CLI then reported ENOENT for that invented location instead of the field's local-filesystem-path requirement.Problem and expected behavior
Smallest trigger:
rea capture-electron-scenario '{"executable_path":"file:///opt/electron","application_path":"<abs>/main.js"}' --format json.invalid_requestwithCannot resolve executable_path <cwd>\file:\opt\electron: ENOENT …. The caller's input was rewritten and they are pointed at the wrong location.invalid_requestonexecutable_pathwith the shared schema message "Electron executable, application, and root paths must be absolute local filesystem paths …". No filesystem lookup of an invented path happens.Violated invariant (AGENTS.md): absolute paths, file URLs and HTTP paths have different semantics, and caller-selected inputs must be preserved.
Change and scope
src/cliJsonInput.ts:resolveCliJsonPathsleaves values matchingfile:orscheme://unchanged, so the shared schema's existing absolute-local-path refinement rejects them. One-letter prefixes stay paths, so Windows drive paths (C:\…) and relative names containing a colon (release:v1/electron) still resolve exactly as before.capture-electron-scenarioand the browser scenariobrowser.executable_path, so both get the fix.Contribution scope: ordinary CLI input fix; maintainer decision not applicable.
Contract and boundary impact
Expected effects:
None of these apply: input validation only.
Evidence and regression coverage
tests/acceptance/applications/electronInvalidPaths.test.ts, "rejects a file URL path field without resolving an invented local path": runs the compiled CLI. It asserts exit code 1,invalid_requestonexecutable_pathwith the local-path message, and no ENOENT.src/cliJsonPaths.test.ts:file:///opt/electron,FILE:electronandhttps://example.test/appstay unchanged and are rejected byelectronActiveObservationInputSchemaonexecutable_path. Controlsbin/electron,release:v1/electronandC:\Electron\electron.exestill resolve.src/cliJsonInput.tsreverted, the 3 URL unit cases and the CLI case fail. The CLI receivedCannot resolve executable_path C:\…\rea\file:\opt\electron: ENOENT. The controls pass both before and after.{"code":"invalid_request", … "issues":[{"path":["executable_path"], … "message":"Electron executable, application, and root paths must be absolute local filesystem paths (for example /Applications/Electron.app/Contents/MacOS/Electron)"}]}Validation performed
Windows 11, Node.js 24.18.0, npm 11.16.0, on
mainat688defca0:npm run test:local -- src/cliJsonPaths.test.ts: 3 failed without the fix; 13/13 with it.npm run test:focused -- tests/acceptance/applications/electronInvalidPaths.test.ts: the new case failed without the fix; 2/2 with it.npm run test:focused --the 38 test files referencing Electron/browser scenario paths orexecutable_path: the same 23 tests fail with and without this change, which makes them pre-existing on Windows. For example,scenarioCliInputDiagnosticslooks for rawC:\…paths inside JSON-escaped output. The only differences between the runs are the 4 new tests, which fail without the fix and pass with it.npm run check:fast(typecheck and lint): passed, including as the pre-push hook.npm run verify:module-boundariesandoxfmt --checkon changed files: passed.Compatibility, safety, and release
Before merge
type(scope): outcome.🤖 Generated with Claude Code