Skip to content

feat: add --dry-run flag to resource and raw HTTP commands#1512

Merged
bernerd-stripe merged 4 commits intomasterfrom
bernerd/dry-run
Mar 26, 2026
Merged

feat: add --dry-run flag to resource and raw HTTP commands#1512
bernerd-stripe merged 4 commits intomasterfrom
bernerd/dry-run

Conversation

@bernerd-stripe
Copy link
Copy Markdown
Contributor

Reviewers

r?
cc @stripe/developer-products

Summary

Adds a --dry-run flag to all resource commands (stripe customers create, stripe billing meters list, etc.) and the raw HTTP commands (stripe get, stripe post, stripe delete).

When set, the command prints a JSON preview of the request that would be sent — method, URL, params, and headers — without making any network calls.

Example:

$ stripe customers create --email [email protected] --dry-run
{
  "dry_run": {
    "method": "POST",
    "url": "https://api.stripe.com/v1/customers",
    "params": {
      "email": "[email protected]"
    },
    "headers": {
      "Authorization": "Bearer sk_test_************cdef",
      "Content-Type": "application/x-www-form-urlencoded"
    }
  }
}

Behavior:

  • Works without a configured API key — Authorization is omitted from the output rather than failing
  • API key is redacted in the output (last 4 chars visible)
  • Supports both v1 (form-encoded) and v2 (JSON body) paths, including bracket-notation param nesting (metadata[env]=staging)
  • Pagination, expand, idempotency, Stripe-Account, and Stripe-Context params/headers are reflected accurately

Testing:

  • Unit tests cover header construction, param parsing (v1 bracket notation, v2 JSON), API-key-absent case, and optional headers
  • Parity tests verify that dry-run params match what a live run actually sends for both v1 and v2 paths

bernerd-stripe and others added 2 commits March 24, 2026 21:28
Prints a JSON preview of the request that would be sent (method, url,
params, headers) without making a live API call. Supports v1 and v2
paths, typed flag values, bracket-notation -d params, path param
substitution, and redacted Authorization header.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Committed-By-Agent: claude
Verify that dry-run output represents the same semantic data as what the
test server actually receives, for both v1 (form-encoded) and v2 (JSON)
request paths. Catches divergence between BuildDryRunOutput and the live
request-building path.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Committed-By-Agent: claude
@bernerd-stripe bernerd-stripe requested a review from a team as a code owner March 24, 2026 21:32
@tomer-stripe
Copy link
Copy Markdown
Collaborator

this is great, ty! my only question is whether we want to wrap everything in a dry_run key or just render it flat. curious what you were thinking?

@bernerd-stripe
Copy link
Copy Markdown
Contributor Author

my only question is whether we want to wrap everything in a dry_run key or just render it flat. curious what you were thinking?

@tomer-stripe I went back and forth on this a bit too, but the thing that won me over (in consultation with claude) is that resource commands like stripe customers list also output formatted JSON data in the default case, so the dry_run wrapper helps make it abundantly clear to an agent that it's custom dry-run output rather than possibly being a Stripe API response.

@tomer-stripe
Copy link
Copy Markdown
Collaborator

@bernerd-stripe fair point! alright :shipit:

@bernerd-stripe bernerd-stripe merged commit e0f5e72 into master Mar 26, 2026
14 checks passed
@bernerd-stripe bernerd-stripe deleted the bernerd/dry-run branch March 26, 2026 22:17
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.

2 participants