openclaw - ✅(Solved) Fix [Bug]: openclaw sessions list returns exit code 0 despite error output [2 pull requests, 2 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#60905Fetched 2026-04-08 02:45:51
View on GitHub
Comments
2
Participants
1
Timeline
16
Reactions
0
Participants
Timeline (top)
referenced ×11labeled ×2closed ×1cross-referenced ×1

Error Message

When running openclaw sessions list with any argument (e.g., openclaw sessions list 2>&1), the CLI reports an error: error: too many arguments for 'sessions'. Expected 0 arguments but got 1. The error message indicates the sessions subcommand does not accept arguments, but the CLI incorrectly returns success despite the error message being printed to stderr. error found at 2026/4/4 22:40 CST

Fix Action

Fixed

PR fix notes

PR #60923: fix(cli): set non-zero exit code on argument errors

Description (problem / solution / changelog)

Summary

Fixes #60905

When CLI commands receive invalid arguments (e.g., openclaw sessions list), Commander.js prints an error but was returning exit code 0. This broke scripts and monitoring tools that rely on exit codes to detect failures.

Solution

Call program.exitOverride() with a callback that sets process.exitCode = 1 for all errors except help/version displays.

Before

$ openclaw sessions list 2>&1
error: too many arguments for 'sessions'. Expected 0 arguments but got 1.
$ echo $?
0

After

$ openclaw sessions list 2>&1
error: too many arguments for 'sessions'. Expected 0 arguments but got 1.
$ echo $?
1

Test Coverage

Added 3 new unit tests to verify exit code behavior:

  • ✅ Argument errors set exitCode = 1
  • --help sets exitCode = 0 (handles commander.helpDisplayed)
  • --version sets exitCode = 0

Test Plan

  • Unit tests pass: pnpm test src/cli/program/build-program.test.ts
  • Manual test confirms exit code is now 1 on argument errors
  • Help (--help) still exits with code 0
  • Version (--version) still exits with code 0

Changed files

  • src/cli/program/build-program.test.ts (modified, +52/-1)
  • src/cli/program/build-program.ts (modified, +14/-0)

PR #60949: fix(cli): show friendly error for sessions list instead of generic too many arguments

Description (problem / solution / changelog)

Summary

When users run openclaw sessions list, Commander rejects it as "too many arguments for sessions. Expected 0 arguments" without explaining that sessions itself is the list command and list is not a valid subcommand.

This PR adds a dedicated route for sessions list that produces a clear error message guiding users to the correct usage (openclaw sessions without list). The route exits with code 1 to properly signal an error condition.

Fixes #60905

Test plan

  • sessions list shows friendly error and exits with code 1
  • sessions (bare) still works correctly and exits with code 0
  • All existing tests pass

Changed files

  • pnpm-lock.yaml (modified, +2/-0)
  • src/cli/program/routes.ts (modified, +13/-0)

Code Example

openclaw sessions list 2>&1
# Expected: non-zero exit code
# Actual: exit code 0

### Expected behavior

The error message indicates the sessions subcommand does not accept arguments, but the CLI incorrectly returns success despite the error message being printed to stderr.

### Actual behavior

error found at 2026/4/4 22:40 CST

### OpenClaw version

2026.4.2

### Operating system

Windows 11

### Install method

_No response_

### Model

minimax2.7

### Provider / routing chain

minimax

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Bug Description

When running openclaw sessions list with any argument (e.g., openclaw sessions list 2>&1), the CLI reports an error:

error: too many arguments for 'sessions'. Expected 0 arguments but got 1.

Steps to reproduce

However, the command exits with code 0 (success), making it impossible for scripts or monitoring tools to distinguish between a successful run and a failure.

Expected Behavior

  • Command failure should return a non-zero exit code
  • Exit code 0 should only be returned on success

Environment

  • OpenClaw version: 2026.4.2 (commit d74a122)
  • Node.js: v24.14.0
  • Platform: Windows_NT 10.0.26200 (x64)
  • Shell: PowerShell

Reproduction Steps

openclaw sessions list 2>&1
# Expected: non-zero exit code
# Actual: exit code 0

### Expected behavior

The error message indicates the sessions subcommand does not accept arguments, but the CLI incorrectly returns success despite the error message being printed to stderr.

### Actual behavior

error found at 2026/4/4 22:40 CST

### OpenClaw version

2026.4.2

### Operating system

Windows 11

### Install method

_No response_

### Model

minimax2.7

### Provider / routing chain

minimax

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence

```shell

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The issue can be mitigated by modifying the openclaw sessions list command to handle arguments correctly and return a non-zero exit code when an error occurs.

Guidance

  • Verify that the openclaw sessions list command is correctly implemented to handle arguments and return appropriate exit codes.
  • Check the source code of the openclaw CLI to identify where the exit code is being set and modify it to return a non-zero value when an error message is printed.
  • Consider adding input validation to the sessions list subcommand to prevent it from accepting unnecessary arguments.
  • Test the modified command with different scenarios to ensure it returns the correct exit codes.

Example

No code snippet can be provided without access to the openclaw source code.

Notes

The root cause of the issue seems to be related to the implementation of the openclaw sessions list command, specifically how it handles arguments and returns exit codes. Without access to the source code, it's difficult to provide a more detailed solution.

Recommendation

Apply a workaround by modifying the openclaw sessions list command to correctly handle arguments and return non-zero exit codes when errors occur, as this will allow scripts and monitoring tools to distinguish between successful and failed runs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The error message indicates the sessions subcommand does not accept arguments, but the CLI incorrectly returns success despite the error message being printed to stderr.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING