Skip to content

Add a strict exit code and ok flag to dispatch doctor #278

Description

@jongio

Problem

dispatch doctor prints a useful setup report, but it always exits 0, even when the config, session store, session-state directory, or Copilot CLI binary is missing. That makes it useless as a gate in an install script or CI step. Right now the only way to check setup programmatically is to run dispatch doctor --json and parse every field yourself.

flowchart TD
    A[dispatch doctor --strict] --> B[Collect doctor report]
    B --> C{Any critical check failing?}
    C -->|no| D[Print report, exit 0]
    C -->|yes| E[Print report, exit non-zero]
    F[dispatch doctor --json] --> G[Report includes ok: true/false]
Loading

Proposed solution

Make the doctor report scriptable without changing the default behavior:

  • Add an ok boolean to the --json output that is false when any critical check (config path resolvable, session store present, session-state directory present, Copilot CLI found) is failing.
  • Add a --strict flag: dispatch doctor --strict prints the same report but exits non-zero when ok is false. --strict works with --json too.
  • Leave plain dispatch doctor and dispatch doctor --json exiting 0 as they do now, so existing usage does not change.

Define "critical" narrowly: a missing or wrong-type config, session store, or session-state path, or a missing Copilot CLI binary. The Copilot CLI version string and session count stay informational and never fail the check on their own.

Acceptance criteria

  • dispatch doctor --json includes an ok boolean reflecting whether all critical checks passed.
  • dispatch doctor --strict exits non-zero when a critical check fails and 0 when everything passes.
  • --strict combines with --json.
  • Plain dispatch doctor and dispatch doctor --json still exit 0 regardless of check results.
  • Help text documents --strict; completion lists it.
  • Unit tests cover the healthy path (ok true, exit 0) and a failing path (ok false, strict exit non-zero).

Notes

collectDoctorReport already gathers every check into a struct, so ok is a small addition. The doctor branch in handleArgs returns an error to main, which already exits 1 on a non-nil error without printing extra text, so wiring the strict exit is straightforward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestideaFeature idea from the idea pipeline

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions