fix(cli): agents diagnostics returns exit code 0 even when errors are found #3908

Open
opened 2026-04-06 07:20:30 +00:00 by hurui200320 · 2 comments
Member

Metadata

  • Commit Message: fix(cli): agents diagnostics returns exit code 0 even when errors are found
  • Branch: fix/diagnostics-exit-code

Background

The agents diagnostics command performs health checks and reports errors, warnings, and successes. However, the process exit code is always 0 regardless of whether errors were found. This makes it unusable for CI/CD pipelines and scripting where non-zero exit codes are expected to signal failure.

Current Behavior

$ agents diagnostics
# ... table output showing 1 error ...
╭── Summary ─────╮
│ Checks: 18 total│
│ Warnings: 7     │
│ Errors: 1       │
╰─────────────────╯
ERROR 1 errors must be resolved

$ echo $?
0   # ← Should be non-zero!

The command displays "ERROR 1 errors must be resolved" but exits with code 0.

Expected Behavior

  • Exit code 0 when all checks pass (no errors)
  • Exit code 1 (or another non-zero code) when one or more errors are found
  • Warnings alone should not cause a non-zero exit code (they are advisory)
  • Optionally: --check flag or --strict flag to also fail on warnings (for CI use)

Subtasks

  • Update diagnostics command to return non-zero exit code when errors are found
  • Ensure warnings alone do not trigger non-zero exit (unless --strict flag is used)
  • Consider adding --check or --strict flag for CI pipelines
  • Tests (Behave): Add scenarios verifying exit codes for pass/warn/error states
  • Tests (Robot): Add integration test for diagnostics exit code behavior
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `fix(cli): agents diagnostics returns exit code 0 even when errors are found` - **Branch**: `fix/diagnostics-exit-code` ## Background The `agents diagnostics` command performs health checks and reports errors, warnings, and successes. However, the process exit code is always 0 regardless of whether errors were found. This makes it unusable for CI/CD pipelines and scripting where non-zero exit codes are expected to signal failure. ## Current Behavior ```bash $ agents diagnostics # ... table output showing 1 error ... ╭── Summary ─────╮ │ Checks: 18 total│ │ Warnings: 7 │ │ Errors: 1 │ ╰─────────────────╯ ERROR 1 errors must be resolved $ echo $? 0 # ← Should be non-zero! ``` The command displays "ERROR 1 errors must be resolved" but exits with code 0. ## Expected Behavior - Exit code 0 when all checks pass (no errors) - Exit code 1 (or another non-zero code) when one or more errors are found - Warnings alone should not cause a non-zero exit code (they are advisory) - Optionally: `--check` flag or `--strict` flag to also fail on warnings (for CI use) ## Subtasks - [ ] Update diagnostics command to return non-zero exit code when errors are found - [ ] Ensure warnings alone do not trigger non-zero exit (unless --strict flag is used) - [ ] Consider adding `--check` or `--strict` flag for CI pipelines - [ ] Tests (Behave): Add scenarios verifying exit codes for pass/warn/error states - [ ] Tests (Robot): Add integration test for diagnostics exit code behavior - [ ] Verify coverage >=97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
Owner

Thank you for filing this issue, @hurui200320. This is a clear and well-documented bug — the exit code behavior is critical for CI/CD integration.

Triage assessment:

This issue is well-formed and clearly actionable. It currently has State/Unverified, Priority/Medium, and Type/Bug labels.

Completeness check per CONTRIBUTING.md:

  • Clear title
  • Background/context
  • Current vs expected behavior with shell output examples
  • Subtasks checklist
  • Definition of Done
  • Metadata (commit message, branch name)
  • ⚠️ Missing: Parent Epic link — this should be linked to an appropriate CLI epic.

Priority assessment: Priority/Medium is appropriate. Exit code correctness is important for CI/CD integration and scripting. The --strict flag suggestion for warnings is a good enhancement idea.

Story Points estimate: XS (1 point) — this is a small, focused fix. The core change is adding a raise typer.Exit(code=1) (or raise SystemExit(1)) when errors are found. The --strict flag is a minor addition.

Spec alignment: The specification should define the expected exit codes for agents diagnostics. If it does not, this may warrant a minor spec update proposal.

This issue is ready for verification and implementation.


Automated by CleverAgents Bot
Supervisor: Human Liaison | Agent: ca-human-liaison

Thank you for filing this issue, @hurui200320. This is a clear and well-documented bug — the exit code behavior is critical for CI/CD integration. **Triage assessment:** This issue is well-formed and clearly actionable. It currently has `State/Unverified`, `Priority/Medium`, and `Type/Bug` labels. **Completeness check per CONTRIBUTING.md:** - ✅ Clear title - ✅ Background/context - ✅ Current vs expected behavior with shell output examples - ✅ Subtasks checklist - ✅ Definition of Done - ✅ Metadata (commit message, branch name) - ⚠️ Missing: Parent Epic link — this should be linked to an appropriate CLI epic. **Priority assessment**: `Priority/Medium` is appropriate. Exit code correctness is important for CI/CD integration and scripting. The `--strict` flag suggestion for warnings is a good enhancement idea. **Story Points estimate**: XS (1 point) — this is a small, focused fix. The core change is adding a `raise typer.Exit(code=1)` (or `raise SystemExit(1)`) when errors are found. The `--strict` flag is a minor addition. **Spec alignment**: The specification should define the expected exit codes for `agents diagnostics`. If it does not, this may warrant a minor spec update proposal. This issue is ready for verification and implementation. --- **Automated by CleverAgents Bot** Supervisor: Human Liaison | Agent: ca-human-liaison
Owner

Automated transition plan for issue #3908:

Current labels: State/Unverified, Priority/Medium, Type/Bug

Preconditions:

  • Not transitioning from Paused
  • No Blocked label (since target is not In Progress) - OK
  • No blocking requirement

Transition plan:

  • Remove old state label: State/Unverified
  • Add new state label: State/Verified

Note: The Forgejo API wrapper used here does not expose label management endpoints. I have not yet performed the label updates programmatically. Please grant permission or confirm to perform label changes via the Forgejo API or UI.

Acceptance criteria mapping:

  • Label changes prepared as above
  • No other labels touched
  • Issue status remains open until upstream automation applies label changes

Next steps: Once label endpoints are available or I receive confirmation, I will apply the label updates and provide a final report of removed/added labels, and update the signature.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-state-updater

Automated transition plan for issue #3908: Current labels: State/Unverified, Priority/Medium, Type/Bug Preconditions: - Not transitioning from Paused - No Blocked label (since target is not In Progress) - OK - No blocking requirement Transition plan: - Remove old state label: State/Unverified - Add new state label: State/Verified Note: The Forgejo API wrapper used here does not expose label management endpoints. I have not yet performed the label updates programmatically. Please grant permission or confirm to perform label changes via the Forgejo API or UI. Acceptance criteria mapping: - Label changes prepared as above - No other labels touched - Issue status remains open until upstream automation applies label changes Next steps: Once label endpoints are available or I receive confirmation, I will apply the label updates and provide a final report of removed/added labels, and update the signature. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-state-updater
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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
cleveragents/cleveragents-core#3908
No description provided.