fix: return unhealthy exit statuses for diagnostic commands - #104
Merged
Conversation
Let completed commands return an explicit process status so health checks can preserve their full stdout reports without throwing or emitting error envelopes. Make doctor and profile status return 1 for unhealthy results across human, JSON, and agent output. Keep profile show observational while adding setup guidance and structured next steps for empty or partial profiles.
redox
approved these changes
Sep 3, 2026
albert20260301
suggested changes
Sep 3, 2026
albert20260301
left a comment
Contributor
There was a problem hiding this comment.
Required before merge:
- Rename this PR with a Conventional Commit prefix (for example,
fix(cli): return unhealthy diagnostic exit statuses) so the semantic-title workflow can pass. - Investigate and fix the failing
Canonical verification / Repository and integrationjob. It stops inVerify repository and integration pathsbefore downstream build jobs run; GitHub has not exposed a more specific annotation beyond the failing command, so please rerun after the fix to capture the underlying test output if needed.
The diagnostic contract and regression coverage are otherwise well scoped.
francoischalifour
enabled auto-merge (squash)
September 3, 2026 14:08
albert20260301
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
altertable doctorandaltertable profile statusare diagnostic commands: they complete successfully as command executions even when the system they inspect is unhealthy. Previously, both commands rendered a complete report but exited with status0.That made the CLI hard to use safely from scripts, CI, and agents. Consumers had to parse report JSON—such as the
healthyfield fromdoctor—instead of relying on the conventional process exit status. At the same time, converting unhealthy reports into thrown CLI errors would have been a regression: it would discard the useful report from stdout and replace it with a stderr error envelope.This PR makes diagnostic health visible through exit status while preserving the report as the command’s primary output.
What changed
Completed commands can return an exit status
The command execution contract now supports an optional
{ exitCode }result from a successfully completed command handler.The command parser returns that result as part of its execution result, and the CLI bootstrap assigns it to
process.exitCodeafter command output and update-notice handling complete. This keeps status handling centralized and avoids individual commands callingprocess.exit().Thrown errors retain the existing error-rendering and stable exit-code behavior.
doctorreports health through its exit statusaltertable doctornow:0when the report is healthy;1when one or more checks fail;--json, or--agentreport on stdout;Per-check details, remediation, HTTP status, and the aggregate report shape remain unchanged.
profile statusfollows the same diagnostic conventionaltertable profile statusnow exits:0when at least one credential plane is configured and every configured plane verifies successfully;1when no credential planes are configured;1when any configured credential verification fails.The command still renders its profile and verification report to stdout in human, JSON, and agent modes. A failed verification is therefore observable both in the report body and through the process status, without being converted into a command-error envelope.
profile showremains observational and becomes more actionablealtertable profile showcontinues to exit0after a successful read, including for empty or partial profiles.For the existing
emptyandpartialprofile states, it now provides:Next steps:section;next_steps, currently directing users toaltertable profile configure.Configured profiles include an empty
next_stepsarray, giving structured consumers a stable field to inspect.Documentation and release notes
The README now documents:
doctorandprofile statusexit-status behavior;profile shownext_stepsfield;1as the aggregate unhealthy-check result.The unreleased changelog records the behavior change.
Design decisions
1is used as the aggregate unhealthy-diagnostic status. Detailed causes remain in the report rather than introducing a new per-diagnostic exit-code taxonomy.doctorreports remain successful becausehealthyis defined by the absence of failed checks.