Skip to content

fix(cli): show clean errors for missing input files - #105874

Merged
steipete merged 3 commits into
openclaw:mainfrom
xialonglee:fix/cli-enoent-error-leak
Jul 18, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
xialonglee:fix/cli-enoent-error-leak

Conversation

@xialonglee

@xialonglee xialonglee commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Three CLI input paths exposed raw Node.js ENOENT text when the user supplied a missing file:

  • openclaw config set --batch-file <path>
  • openclaw config patch --file <path>
  • openclaw secrets apply --from <path>

The raw filesystem error is noisy and less actionable than naming the flag and user-supplied path.

Solution

  • Translate only ENOENT at each command-owned file-read boundary using the shared hasErrnoCode guard.
  • Preserve the original error as cause; rethrow every non-ENOENT failure unchanged.
  • Use a typed local missing-plan error so secrets rendering suppresses only that expected raw cause. Unrelated apply errors, including ones with similar message text, retain their diagnostic causes.

Behavior

The three commands now exit 1 with these messages:

Error: --batch-file not found: /tmp/missing-batch.json5
Error: --file not found: /tmp/missing-patch.json5
Secrets apply failed: Secrets plan file not found: /tmp/missing-plan.json. Re-run openclaw secrets apply --from <path> --dry-run to inspect the plan without writing.

No parse, config write, or secrets apply operation runs after the missing input is detected.

Evidence

  • Blacksmith Testbox tbx_01kxstbgzscnwa3jeeqyr62j8h: pnpm test src/cli/config-set-input.test.ts src/cli/config-cli.test.ts src/cli/secrets-cli.test.ts — 160 passed.
  • Real built CLI on the same Testbox: all three commands exited 1 with the expected text; combined output contained neither ENOENT nor no such file or directory.
  • Fresh maintainer-fixup autoreview: clean (patch is correct, 0.98).
  • git diff --check — clean.

Risk

Low. Success paths are unchanged. Classification is limited to ENOENT; permission, parse, validation, and provider errors keep their existing handling.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels Jul 13, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 13, 2026
@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 1:32 AM ET / 05:32 UTC.

Summary
The PR replaces raw missing-file ENOENT output with command-specific errors for config set --batch-file, config patch --file, and secrets apply --from, with regression tests for each path.

PR surface: Source +38, Tests +48. Total +86 across 6 files.

Reproducibility: yes. The three missing-path inputs have direct source paths and focused regression tests, and the PR body reports built-CLI runs that exit 1 with the intended text without invoking configuration writes or secrets apply.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Allow the required exact-head CI checks to finish, then complete ordinary maintainer review.

Next step before merge

  • [P2] No mechanical repair remains; this needs the assigned reviewer’s ordinary merge decision after the final exact-head CI gate.

Security
Cleared: The diff changes local CLI error classification and rendering only; it adds no dependency, workflow, permission, secret, download, or execution surface.

Review details

Best possible solution:

Merge the narrow command-owned ENOENT translations after required checks pass, keeping the typed secrets wrapper limited to the expected missing-plan rendering path.

Do we have a high-confidence way to reproduce the issue?

Yes. The three missing-path inputs have direct source paths and focused regression tests, and the PR body reports built-CLI runs that exit 1 with the intended text without invoking configuration writes or secrets apply.

Is this the best way to solve the issue?

Yes. Translating only ENOENT at each command-owned read boundary with the canonical errno guard is narrower and safer than global error-string rewriting; the typed secrets error prevents suppressing unrelated diagnostic causes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6709693d3958.

Label changes

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P3: This is a bounded CLI diagnostics improvement with no demonstrated data, authentication, delivery, or availability impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix built-CLI evidence for all three commands: each exits 1 with the expected user-facing text and combined output omits raw ENOENT and filesystem wording.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix built-CLI evidence for all three commands: each exits 1 with the expected user-facing text and combined output omits raw ENOENT and filesystem wording.
Evidence reviewed

PR surface:

Source +38, Tests +48. Total +86 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 43 5 +38
Tests 3 48 0 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 91 5 +86

What I checked:

  • Exact-head implementation scope: The PR changes only the three owning file-read boundaries: batch input parsing, config patch input parsing, and secrets plan loading; each catches only ENOENT, preserves it as cause, and rethrows all other failures. (src/cli/config-set-input.ts:137, 0b7e9424a77e)
  • Shared errno contract: The config patch and batch-file paths use the repository’s shared hasErrnoCode guard rather than matching error text, addressing the earlier review concern while preserving permission, parse, and validation errors. (src/cli/config-cli.ts:1504, 0b7e9424a77e)
  • Secrets cause rendering is scoped: A dedicated SecretsPlanFileNotFoundError suppresses the expected raw filesystem cause only for a missing plan; the added sibling test verifies unrelated errors with a similar message still render their diagnostic cause. (src/cli/secrets-cli.ts:46, 0b7e9424a77e)
  • Regression coverage: The branch adds focused tests for a nonexistent --batch-file, --file, and secrets --from path, including assertions that no config write or secrets apply runs after the error. (src/cli/secrets-cli.test.ts:399, 0b7e9424a77e)
  • Maintainer follow-up provenance: The current head includes maintainer-authored follow-ups that type the secrets missing-plan error and format the branch; the PR is assigned to the same recent contributor, so it should not be auto-closed. (src/cli/secrets-cli.ts:46, 97db300d4f57)

Likely related people:

  • steipete: Authored the current secrets-specific follow-up commits and is assigned to this PR, directly connecting them to the final error-rendering behavior. (role: recent area contributor and assigned reviewer; confidence: high; commits: 97db300d4f57, 0b7e9424a77e; files: src/cli/secrets-cli.ts)
  • xialonglee: Authored the underlying CLI-boundary change and regression coverage on the branch; included for implementation context rather than as a current-main ownership claim. (role: original implementation contributor; confidence: medium; commits: bff83b558f7f; files: src/cli/config-set-input.ts, src/cli/config-cli.ts, src/cli/secrets-cli.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-17T01:56:40.061Z sha e373b9f7a8dd3e09812e328079244771b6d053cb :: needs changes before merge. :: [P1] Reuse the canonical errno guard
  • reviewed 2026-07-17T02:57:11.867Z sha a3e5b090fe1c1800ac577585d3eb5116ee081206 :: needs changes before merge. :: [P1] Reuse the canonical errno guard
  • reviewed 2026-07-17T10:16:41.810Z sha f09588bf6fb89cc9b26d478957155ed76f3bd819 :: needs real behavior proof before merge. :: [P2] Keep the secrets ENOENT cause out of rendered output
  • reviewed 2026-07-17T10:58:24.985Z sha f09588bf6fb89cc9b26d478957155ed76f3bd819 :: needs real behavior proof before merge. :: [P2] Keep the secrets ENOENT cause out of rendered output
  • reviewed 2026-07-17T12:13:00.093Z sha bff83b5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T12:56:01.822Z sha bff83b5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T13:30:11.119Z sha bff83b5 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-18T05:24:44.422Z sha 97db300 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 13, 2026
@xialonglee

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@xialonglee

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 14, 2026
@xialonglee
xialonglee force-pushed the fix/cli-enoent-error-leak branch from 853a90d to e373b9f Compare July 17, 2026 01:50
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 17, 2026
@xialonglee
xialonglee force-pushed the fix/cli-enoent-error-leak branch from e373b9f to a3e5b09 Compare July 17, 2026 02:51
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 17, 2026
@xialonglee
xialonglee force-pushed the fix/cli-enoent-error-leak branch from f09588b to bff83b5 Compare July 17, 2026 12:07
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 17, 2026
@steipete steipete self-assigned this Jul 18, 2026
@steipete steipete changed the title fix(cli): wrap readFileSync ENOENT with user-friendly error messages fix(cli): show clean errors for missing input files Jul 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 18, 2026
@steipete
steipete merged commit cafa760 into openclaw:main Jul 18, 2026
122 of 124 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
* fix(cli): wrap readFileSync ENOENT with user-friendly messages and suppress cause leak

* fix(secrets): type missing plan errors

* style(secrets): format missing plan error branch

---------

Co-authored-by: Peter Steinberger <[email protected]>
@xialonglee
xialonglee deleted the fix/cli-enoent-error-leak branch July 18, 2026 09:04
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* fix(cli): wrap readFileSync ENOENT with user-friendly messages and suppress cause leak

* fix(secrets): type missing plan errors

* style(secrets): format missing plan error branch

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants