Skip to content

fix(cli): nodes push test still expects silent JSON-mode failures - #200199

Merged
fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/nodes-push-json-diagnostic-test
Nov 16, 2026
Merged

fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/nodes-push-json-diagnostic-test

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: src/cli/program.nodes-diagnostics-auth.e2e.test.ts › "rejects environment staging before lookup (JSON: true)" fails on main every run since 25c9790 (#199970). It fails checks-node-changed on any PR whose changed lanes select it, for example #200181 (job 133469711316), which does not touch the nodes CLI.

AssertionError: expected [Function] to throw error including 'invalid --environment (use sandbox|production)' but got 'exit'
 ❯ src/cli/program.nodes-diagnostics-auth.e2e.test.ts:290:9

User Impact

User impact: none for people running OpenClaw. Contributors stop getting this red check on unrelated PRs. No production file changes.

Why This Change Was Made

#199970 changed runCommandWithRuntime on purpose: in --json mode a plain command error now goes through the same diagnostic path as text mode, and the wrapper then throws ReportedCliCommandError so the JSON failure owner keeps the original envelope. Its PR text says the nodes subprocess assertions were updated to require the concrete diagnostic. This in-process case was not: it still asserted that JSON mode calls neither runtime.error nor runtime.exit.

With the new wrapper, the nodes error handler runs in JSON mode, prints nodes push failed: … and calls runtime.exit(1). The shared test runtime's exit throws a plain Error("exit"). The wrapper only converts the ExitError the real defaultRuntime.exit throws, so the plain error propagated and the case saw exit instead of the environment message.

The JSON case now:

  • makes the runtime mock throw the real ExitError for that one call, as defaultRuntime.exit does;
  • still requires the rejection to carry invalid --environment (use sandbox|production), which is what the JSON failure owner formats;
  • requires the diagnostic exactly once on stderr and exactly one exit(1), in both modes;
  • still requires an empty stdout and no Gateway call before lookup.

The text-mode case is unchanged apart from the exit assertion becoming exactly-once.

Evidence

Head 591cd62 on base 94e34f9. Command for every run: node scripts/run-vitest.mjs src/cli/program.nodes-diagnostics-auth.e2e.test.ts.

Red, unmodified main

Commit Result
98c732c (parent of #199970) 18 passed, 2 of 2 runs
25c9790 (#199970) 1 failed, 17 passed
6f5d3b3 (base of #200181) 1 failed, 17 passed, 2 of 2 runs
4a74c61 (main when this branch was cut) 1 failed, 17 passed

Green, this change

  • 3 of 3 runs on the first cut, then 1 run after rebasing onto 94e34f9: 18 passed each. Main moved between the two; the range touches nothing under src/cli or src/runtime.ts, so I did not repeat the three runs.
  • Negative control (temporary edit, reverted): with runCommandWithRuntime rethrowing in JSON mode before reporting, as it did before fix(cli): retain command diagnostics in JSON failures #199970, the JSON case fails on the missing diagnostic.
  • oxfmt --check on the file and git diff --check: clean.
  • OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 node scripts/check-changed.mjs: exit 0, including the core test typecheck and lint for the changed file. The dead-export scan is skipped because it currently fails on main for files this PR does not touch.

Audit of the touched test file

  • Read all 18 cases, the two describe blocks, helpers, imports and the process.argv / process.exitCode restore in afterEach.
  • This is the only case that asserted JSON-mode silence for a plain error. The nodes status credentials case that expects no runtime.error goes through the expected-error path, which fix(cli): retain command diagnostics in JSON failures #199970 left unchanged, and still passes.
  • mockImplementationOnce is consumed by the single exit call and vi.clearAllMocks() runs in beforeEach, so nothing leaks into later cases.
  • Nothing was removed or skipped.

Not run

  • The wider CLI suites; CI covers them.
  • The autoreview helper cannot run on this machine. The change is one test case and was read against src/cli/cli-utils.ts and src/runtime.ts on the head.

openclaw#199970 made commands that run through the shared wrapper report their
diagnostic in --json mode as they do in text mode. The in-process nodes push
case still asserted that JSON mode writes nothing to stderr and never exits,
so it has failed on main since 25c9790 and fails the changed-files check
of any PR whose lanes select it.

The JSON case now requires the diagnostic exactly once, the exit, an empty
stdout and no Gateway call, and that the error reaching the JSON failure
owner still carries the original message. The runtime mock throws the same
ExitError the real runtime throws, because that is the exit the wrapper
converts for JSON output.
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 16, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 4940240 into openclaw:main Nov 16, 2026
93 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/nodes-push-json-diagnostic-test branch November 16, 2026 18:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…enclaw#200199)

openclaw#199970 made commands that run through the shared wrapper report their
diagnostic in --json mode as they do in text mode. The in-process nodes push
case still asserted that JSON mode writes nothing to stderr and never exits,
so it has failed on main since 3411f31 and fails the changed-files check
of any PR whose lanes select it.

The JSON case now requires the diagnostic exactly once, the exit, an empty
stdout and no Gateway call, and that the error reaching the JSON failure
owner still carries the original message. The runtime mock throws the same
ExitError the real runtime throws, because that is the exit the wrapper
converts for JSON output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant