Skip to content

fix: stop --dry-run reporting an API error on commands that return 201 - #39

Closed
Bradenream wants to merge 2 commits into
masterfrom
braden/dry-run-create/COR-0
Closed

Bradenream wants to merge 2 commits into
masterfrom
braden/dry-run-create/COR-0

Conversation

@Bradenream

@Bradenream Bradenream commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

--dry-run swaps the HTTP client for one that prints the request and, instead of sending it, hands the SDK a stand-in 200. The SDK accepts only an operation's documented success code. 28 of the 191 operations succeed with 201 alone: every create, plus environment clone, environment publish, evaluation run and test run create. Their dry runs printed the preview, then API Error (HTTP 200): unknown status code returned, and exited 1.

The stand-in response now carries an X-Vf-Dry-Run header. While --dry-run is on, output.Error, which every generated command reports SDK errors through, does not report an error about that response (internal/output/dryrun.go). The flag check matters: a header is something any server reached with --server-url could send, and it must not turn that server's error into a silent success. Errors raised before the preview, such as a body that fails to serialize, carry no response and are still reported. Commands that already worked are unchanged, including the {} that a 200 operation prints with --output-format json.

Before and after

master this PR
All 191 API commands, dry run with placeholder flags: commands that print the preview and then fail 23 0
The other 5 of the 28, run by hand all fail all exit 0
test/dry-run.test.ts (6 cases) 3 fail 6 pass

Test plan

--dry-run swaps the HTTP client for one that prints the request and,
instead of sending it, hands the SDK a stand-in 200. The SDK accepts only
an operation's documented success code, and 28 of the 191 operations
succeed with 201 alone: every create, plus environment clone and publish,
evaluation run and test run create. Their dry runs printed the preview,
then "API Error (HTTP 200): unknown status code returned", and exited 1.

The stand-in response now carries an X-Vf-Dry-Run header. output.Error,
which every generated command reports SDK errors through, does not
report an error about that response. Errors raised before the preview,
such as a body that fails to serialize, carry no response and are still
reported. Commands that already worked are unchanged.

Checked against all 191 API commands, run with placeholder flags. Of the
ones the placeholders could build, master printed the preview and then
failed 23; with this change none fail. The other 5 of the 28 were
checked by hand: each failed on master and now exits 0.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Error suppression must also verify that dry-run mode is active to prevent real server responses from being treated as success.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes --dry-run failures for API operations expecting HTTP 201.

Changes:

  • Marks synthetic dry-run responses and suppresses their SDK status errors.
  • Adds unit and behavior coverage for dry-run success and genuine failures.
File Description
internal/​client/​diagnostics.go Marks synthetic responses.
internal/​client/​diagnostics_test.go Tests response marking.
internal/​output/​dryrun.go Detects marked responses.
internal/​output/​dryrun_test.go Tests error suppression.
internal/​output/​output.go Ignores synthetic-response errors.
test/​dry-run.test.ts Adds end-to-end coverage.
Files not reviewed (2)
  • internal/client/diagnostics.go: Generated file
  • internal/output/output.go: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/output/output.go
output.Error skipped any error whose response carried X-Vf-Dry-Run. A
header is something any server reached with --server-url can send, so a
server could have turned its own error into a silent exit 0, without a
dry run ever being asked for. Copilot raised this in review.

The marker now counts only while --dry-run is on. During a dry run
nothing is sent, so the stand-in is the only response there can be.
A test server that answers a real request with the marker and an
unexpected status shows the difference: before, vf exited 0; now it
reports the error and exits 1.

effervescentia commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Merge activity

  • Oct 2, 3:36 PM UTC: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Oct 2, 3:36 PM UTC: effervescentia added this pull request to the Graphite merge queue.
  • Oct 2, 3:37 PM UTC: CI is running for this pull request on a draft pull request (#44) due to your merge queue CI optimization settings.
  • Oct 2, 3:37 PM UTC: Merged by the Graphite merge queue via draft PR: #44.

@graphite-app graphite-app Bot closed this Oct 2, 2026
@graphite-app
graphite-app Bot deleted the braden/dry-run-create/COR-0 branch October 2, 2026 15:37
@graphite-app graphite-app Bot removed the merge label Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants