[PR #5036] [MERGED] fix(electron): report rejected CLI arguments with issue details #6749

Closed
opened 2026-11-01 21:42:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5036
Author: @KhangKT1310
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @morluto

Base: main ← Head: fix/electron-cli-input-diagnostics


📝 Commits (2)

  • b9c9fb7 fix(electron): report rejected CLI arguments with issue details
  • 6bc053c test(electron): assert exit code 1 on rejected CLI arguments

📊 Changes

2 files changed (+77 additions, -11 deletions)

View changed files

📝 src/cli/electronCommands.ts (+18 -6)
📝 tests/boundary/cli/electronCli.test.ts (+59 -5)

📄 Description

Summary

Fixes #3865

When list-electron-targets or inspect-electron-page CLI commands receive invalid arguments, input schema validation fails, but the commands previously returned a generic invalid_request error without details.issues. This change forwards parsed.error.issues and input to inputError, reporting structured issue details naming the rejected fields (cdp_endpoint, target_id, etc.) and failure reasons, matching the diagnostic behavior of browserCommands.

Problem and expected behavior

Prior behavior:
Running rea list-electron-targets 'not a url' --json or rea inspect-electron-page http://127.0.0.1:9222 '' --json failed with exit 1 and returned:

{
  "error": "Electron analysis failed",
  "code": "invalid_request",
  "category": "invalid_input",
  "message": "Analysis input is invalid. Check the arguments and try again.",
  "retryable": true,
  "remediation": {
    "action": "Correct the listed arguments and retry."
  }
}

The error lacked details.issues, omitting which argument was rejected and why.

Expected behavior:
The CLI returns invalid_request with exit 1 and includes details.issues specifying the invalid field path and reason (e.g. {"path": ["cdp_endpoint"], "reason": "invalid_value", "message": "Invalid CDP endpoint URL"} and {"path": ["target_id"], "reason": "out_of_range", "minimum": 1}), consistent with list-browser-targets and inspect-web-page.

Change and scope

In src/cli/electronCommands.ts:

  • In registerElectronTargetList: define input object and pass parsed.error.issues and input to inputError("list_electron_targets", parsed.error.issues, input).
  • In registerElectronPageInspection: define input object and pass parsed.error.issues and input to inputError("inspect_electron_page", parsed.error.issues, input).

This fits REA's existing inputError helper in src/cli/electronCommands.ts, which already accepts issues and input and projects them via projectInputIssues (ensuring secret redaction and consistent issue schemas).

Follow the contribution scope.
Ordinary fix within existing CLI boundaries; maintainer scope decision: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Request parsing and validation in CLI (src/cli/electronCommands.ts).
  • Contribution scope fit and linked maintainer decision: not applicable (routine CLI diagnostic fix).
  • CLI and MCP/tool-catalog contract: Preserves invalid_request exit code 1; populates details.issues with structured field diagnostics.
  • Provider, bridge, target-format, or platform compatibility: Cross-platform Node.js; no provider engine or bridge protocol changes.
  • Evidence, artifact, provenance, or reconstruction contract: None.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata, package, or installation impact: None.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: Added regression test reports rejected Electron CLI arguments with structured issue details in tests/boundary/cli/electronCli.test.ts.
  • Base reproduction or other evidence: Verified both commands on clean baseline reproduced the omitted details object, and verified the updated commands output structured details.issues.
  • User-visible CLI/MCP output (if applicable):
    node scripts/rea.mjs list-electron-targets "not a url" --json outputs:
    {
      "error": "Electron analysis failed",
      "code": "invalid_request",
      "category": "invalid_input",
      "message": "Analysis input is invalid. Check the arguments and try again.",
      "retryable": true,
      "remediation": { "action": "Correct the listed arguments and retry." },
      "details": {
        "operation": "list_electron_targets",
        "issues": [{ "path": ["cdp_endpoint"], "reason": "invalid_value", "message": "Invalid CDP endpoint URL" }]
      }
    }
    
    node scripts/rea.mjs inspect-electron-page "http://127.0.0.1:9222" "" --json outputs:
    {
      "error": "Electron analysis failed",
      "code": "invalid_request",
      "category": "invalid_input",
      "message": "Analysis input is invalid. Check the arguments and try again.",
      "retryable": true,
      "remediation": { "action": "Correct the listed arguments and retry." },
      "details": {
        "operation": "inspect_electron_page",
        "issues": [{ "path": ["target_id"], "reason": "out_of_range", "minimum": 1 }]
      }
    }
    
  • Remaining proof gaps: Live CDP connection to real Electron instance was not run; fake CDP browser and unit/boundary CLI harnesses exercised.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- tests/boundary/cli/electronCli.test.ts — 8 passed (1 file)
  • npm run check:fast — 2 tasks successful (typecheck, lint)
  • npm run docs:check — 6 tasks successful (docs facts, licenses, metadata, conformance)
  • node scripts/rea.mjs list-electron-targets "not a url" --json — exit 1 with structured details.issues
  • node scripts/rea.mjs inspect-electron-page "http://127.0.0.1:9222" "" --json — exit 1 with structured details.issues

Compatibility, safety, and release

  • Breaking changes or migration steps: None. Additive error detail.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux x64 tested; no native providers involved.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: projectInputIssues redacts secrets and credentials from raw input before returning details.issues.

Author readiness

Human owner: @KhangKT1310

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/5036 **Author:** [@KhangKT1310](https://github.com/KhangKT1310) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/electron-cli-input-diagnostics` --- ### 📝 Commits (2) - [`b9c9fb7`](https://github.com/morluto/rea/commit/b9c9fb7e5c5fb62c9ee37b5538a84de3a32178e8) fix(electron): report rejected CLI arguments with issue details - [`6bc053c`](https://github.com/morluto/rea/commit/6bc053c61a765d0d3c3b89344bf299c27fafa386) test(electron): assert exit code 1 on rejected CLI arguments ### 📊 Changes **2 files changed** (+77 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/cli/electronCommands.ts` (+18 -6) 📝 `tests/boundary/cli/electronCli.test.ts` (+59 -5) </details> ### 📄 Description ## Summary Fixes #3865 When `list-electron-targets` or `inspect-electron-page` CLI commands receive invalid arguments, input schema validation fails, but the commands previously returned a generic `invalid_request` error without `details.issues`. This change forwards `parsed.error.issues` and `input` to `inputError`, reporting structured issue details naming the rejected fields (`cdp_endpoint`, `target_id`, etc.) and failure reasons, matching the diagnostic behavior of `browserCommands`. ## Problem and expected behavior Prior behavior: Running `rea list-electron-targets 'not a url' --json` or `rea inspect-electron-page http://127.0.0.1:9222 '' --json` failed with exit 1 and returned: ```json { "error": "Electron analysis failed", "code": "invalid_request", "category": "invalid_input", "message": "Analysis input is invalid. Check the arguments and try again.", "retryable": true, "remediation": { "action": "Correct the listed arguments and retry." } } ``` The error lacked `details.issues`, omitting which argument was rejected and why. Expected behavior: The CLI returns `invalid_request` with exit 1 and includes `details.issues` specifying the invalid field path and reason (e.g. `{"path": ["cdp_endpoint"], "reason": "invalid_value", "message": "Invalid CDP endpoint URL"}` and `{"path": ["target_id"], "reason": "out_of_range", "minimum": 1}`), consistent with `list-browser-targets` and `inspect-web-page`. ## Change and scope In `src/cli/electronCommands.ts`: - In `registerElectronTargetList`: define `input` object and pass `parsed.error.issues` and `input` to `inputError("list_electron_targets", parsed.error.issues, input)`. - In `registerElectronPageInspection`: define `input` object and pass `parsed.error.issues` and `input` to `inputError("inspect_electron_page", parsed.error.issues, input)`. This fits REA's existing `inputError` helper in `src/cli/electronCommands.ts`, which already accepts `issues` and `input` and projects them via `projectInputIssues` (ensuring secret redaction and consistent issue schemas). Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Ordinary fix within existing CLI boundaries; maintainer scope decision: not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: Request parsing and validation in CLI (`src/cli/electronCommands.ts`). - Contribution scope fit and linked maintainer decision: not applicable (routine CLI diagnostic fix). - CLI and MCP/tool-catalog contract: Preserves `invalid_request` exit code 1; populates `details.issues` with structured field diagnostics. - Provider, bridge, target-format, or platform compatibility: Cross-platform Node.js; no provider engine or bridge protocol changes. - Evidence, artifact, provenance, or reconstruction contract: None. - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable. - Generated metadata, package, or installation impact: None. Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: Added regression test `reports rejected Electron CLI arguments with structured issue details` in `tests/boundary/cli/electronCli.test.ts`. - Base reproduction or other evidence: Verified both commands on clean baseline reproduced the omitted `details` object, and verified the updated commands output structured `details.issues`. - User-visible CLI/MCP output (if applicable): `node scripts/rea.mjs list-electron-targets "not a url" --json` outputs: ```json { "error": "Electron analysis failed", "code": "invalid_request", "category": "invalid_input", "message": "Analysis input is invalid. Check the arguments and try again.", "retryable": true, "remediation": { "action": "Correct the listed arguments and retry." }, "details": { "operation": "list_electron_targets", "issues": [{ "path": ["cdp_endpoint"], "reason": "invalid_value", "message": "Invalid CDP endpoint URL" }] } } ``` `node scripts/rea.mjs inspect-electron-page "http://127.0.0.1:9222" "" --json` outputs: ```json { "error": "Electron analysis failed", "code": "invalid_request", "category": "invalid_input", "message": "Analysis input is invalid. Check the arguments and try again.", "retryable": true, "remediation": { "action": "Correct the listed arguments and retry." }, "details": { "operation": "inspect_electron_page", "issues": [{ "path": ["target_id"], "reason": "out_of_range", "minimum": 1 }] } } ``` - Remaining proof gaps: Live CDP connection to real Electron instance was not run; fake CDP browser and unit/boundary CLI harnesses exercised. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- tests/boundary/cli/electronCli.test.ts` — 8 passed (1 file) - `npm run check:fast` — 2 tasks successful (typecheck, lint) - `npm run docs:check` — 6 tasks successful (docs facts, licenses, metadata, conformance) - `node scripts/rea.mjs list-electron-targets "not a url" --json` — exit 1 with structured `details.issues` - `node scripts/rea.mjs inspect-electron-page "http://127.0.0.1:9222" "" --json` — exit 1 with structured `details.issues` ## Compatibility, safety, and release - Breaking changes or migration steps: None. Additive error detail. - Real Hopper/Ghidra, browser, or OS coverage: Linux x64 tested; no native providers involved. - Package or release metadata impact: None. - Security, privacy, process, or containment review: `projectInputIssues` redacts secrets and credentials from raw input before returning `details.issues`. ## Author readiness Human owner: @KhangKT1310 - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:42: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#6749
No description provided.