Skip to content

fix(openspec): check fails in dry run with not JSON #4272

Closed

Description

@dan-petty

Problem

uv run devops --dry-run openspec check prints openspec list --json failed with exit code 0: not JSON: and exits 1 (seen 2026-11-09 on a checkout of main). In a dry run, run_subprocess starts no process and returns exit code 0 with empty output. The gate reads that empty output as the answer of the tool, so it fails with a message that points at the tool, not at the dry run. The cause is the same as in #4270 (archive).

Expected

In a dry run, devops openspec check starts no process, lists the openspec commands the gate would run, and says that it would run the gate. It does not read the output of a planned process.

Acceptance criteria

  • uv run devops ci test tests/openspec/test_openspec_gate.py::test_check_in_dry_run_lists_the_commands - with DEVOPS_CLI_DRY_RUN=1, devops openspec check exits 0, prints the planned openspec commands, and starts no process. Today it exits 1 with not JSON.

Existing tool considered

render_request_plan and PlannedRequest (src/devops_cli/dry_run/requests.py) give the plan output. #4270 uses them for archive. No new tool is needed.

Related

Proposed design

Problem statement

In a dry run, devops openspec check reads the empty output of a planned process as the answer of the openspec tool. It then fails with openspec list --json failed with exit code 0: not JSON: and exits 1. The message points at the tool, not at the dry run. A dry run must start no process, list the planned openspec commands, and exit 0.

Acceptance criteria

Requirement: Dry run lists the gate commands

In a dry run, devops openspec check SHALL start no process, print the openspec commands that the gate would run in order, and exit 0.

Scenario: check_in_dry_run_lists_the_commands

  • WHEN devops openspec check runs with DEVOPS_CLI_DRY_RUN=1 on a tree with no change and no spec
  • THEN The exit code is 0, the output lists the planned openspec commands, and the process runner starts no process.

Requirement: Dry run reads no planned output

In a dry run, the gate MUST NOT parse the output of a planned process, so the command MUST NOT print not JSON.

Scenario: dry_run_prints_no_not_json_error

  • WHEN devops openspec check runs with DEVOPS_CLI_DRY_RUN=1
  • THEN The output holds no not JSON text and no failed with exit code text.

Requirement: Dry run says the gate would run

In a dry run, devops openspec check SHALL state that it would run the gate.

Scenario: dry_run_states_the_intent

  • WHEN devops openspec check runs with DEVOPS_CLI_DRY_RUN=1
  • THEN The output holds a line that says the gate would run, after the list of planned commands.

Requirement: Real run is unchanged

Outside a dry run, check_openspec SHALL run the same commands and report the same findings as before the change.

Scenario: real_run_keeps_the_command_list

  • WHEN check_openspec runs on the empty tree with the openspec_fake
  • THEN The findings are empty and the recorded commands equal EMPTY_TREE_COMMANDS.

Existing Tool Considered

render_request_plan and PlannedRequest in src/devops_cli/dry_run/requests.py give the plan output, and #4270 uses them for archive. No new tool or library is needed. The change adds a small plan function for the gate commands. The cost is low: one plan function, one branch in the command, and two tests.

Key questions

  • How does the command know that it runs in a dry run?: Use the same dry-run check that the other commands use, such as the one in src/devops_cli/dry_run/state.py, in the check command of src/devops_cli/commands/openspec.py. Follow the pattern that fix(openspec): archive reports success and moves nothing #4270 sets for archive. [sources: src/devops_cli/dry_run/state.py, src/devops_cli/commands/openspec.py]
  • Where does the dry-run branch go: in the command, or in check_openspec?: Put the branch in the command in src/devops_cli/commands/openspec.py. It builds a list of PlannedRequest entries and prints them with render_request_plan. check_openspec keeps its code for real runs. (best practice) [sources: src/devops_cli/dry_run/requests.py, src/devops_cli/commands/openspec.py, openspec/changes/archive/2026-10-27-2341-worktrees-prune-merged-pr/design.md]
  • Which commands does the dry run list?: List the fixed commands that the gate runs over a tree with no change: the four config set commands, list --json, the two validate commands, update --force, new change gate-probe and the five instructions commands. A command that depends on the output of an earlier one carries a condition, for example the validation of one change. Each command has the isolated environment variables as env with a placeholder for the scratch directory. (best practice) [sources: tests/openspec/test_openspec_gate.py, src/devops_cli/dry_run/requests.py]
    • Chosen: List the fixed commands, mark the data-dependent ones with condition. The dry-run rule says that a request that runs only after an earlier one names that in condition.
    • Rejected: List only the first command. The expected result says that the plan lists the commands the gate would run.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-10: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/bug
    scope/openspec
    status/new
    value/medium
    effort/low
    on Nov 9, 2026
  2. dan-petty commented on Nov 9, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/openspec. The (openspec) scope of the title gives the scope.
    • Priority: P2-Medium. A functional bug in dry-run mode that misreports a failure; not a data-loss or security issue.
    • Value: Medium. Users who preview openspec check in dry run get a false error and cannot verify the planned commands.
    • Effort: Low. The body states no new tool is needed and the fix mirrors the pattern already used for archive in #4270.
    • Related: fix(openspec): archive reports success and moves nothing #4270, which asks for a different change. Both fix the same dry-run root cause in openspec subcommands but target different commands (check vs archive).
  3. added
    priority/p2-medium
    on Nov 9, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 9, 2026
  5. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at cefc184 (see proposed design in issue body).

  6. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches found no external tool or library for planning subprocess commands in a dry run; they returned only unrelated MDN pages. The issue is an in-repo defect: the check command of src/devops_cli/commands/openspec.py must branch on the existing dry-run state and print the gate's openspec commands with the repository's own render_request_plan/PlannedRequest, which the issue already names as the intended means, so no third-party tool covers the need.

    Tool: none found

    Lacks:

    • No external library provides the repository's dry-run gate plan output; it is built from the in-repo render_request_plan and PlannedRequest.
    • No library can decide which openspec commands the gate would run or mark the data-dependent ones with a condition.
    • No library supplies the dry-run state check that the openspec check command must consult.

    Searches run:

    • dry run mode CLI print planned commands instead of executing library, results: 5
    • Python library render planned subprocess commands without executing (dry run), results: 5

    Checked on 2026-11-10. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 12, 2026
  8. removed
    status/in-progress
    owner/agent
    on Nov 12, 2026
  9. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 06:05 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/openspecsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions