← Back to PRs

#10578: feat(doctor): exit with code 1 when critical errors are detected

by 13rac1 open 2026-02-06 17:50 View on GitHub →
commands stale
A simple feature or arguable bug fix: useful non-zero exit codes for `openclaw doctor` * AI-Assisted * Fully Tested * I confirm I understand what the code does, it is only 13 lines excluding tests. Prompts in Claude Code: * "Create a plan to fail with exit 1 when there it is an error in `openclaw doctor`" * "Add tests" AI generated description from git commit message follows: ``` Previously `openclaw doctor` always exited with code 0, even when it found problems. This made it difficult to use in scripts or CI pipelines that need to detect failures. Now doctor exits with code 1 when any of these critical errors occur: - gateway.mode is unset (blocks gateway start) - Gateway health check fails (gateway not running) - Config file is invalid Warnings and suggestions (auth tips, workspace recommendations, legacy state prompts) do not affect the exit code—only blocking errors do. When errors are found, the outro message changes to "Doctor complete with errors." to make the failure visible in interactive use. ``` <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> - Updates `openclaw doctor` to track whether any blocking errors occurred (missing `gateway.mode`, failed gateway health check, invalid config) and exit with status code 1 in that case. - Adjusts the final outro message to visibly indicate failures in interactive runs ("Doctor complete with errors."). - Adds a new Vitest suite covering exit code behavior for critical errors vs warning-only scenarios. <h3>Confidence Score: 4/5</h3> - This PR is close to safe to merge; main concern is potential test flakiness from process-global mutations without module reset. - The production change is straightforward and localized, but the new test file mutates `process.env` and `process.stdin.isTTY` and relies on dynamic imports without resetting the module cache, which can make results order-dependent in Vitest’s shared process. - src/commands/doctor.exit-codes.test.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs