Skip to content

feat(cli): send --dry-run, preview a request with secrets redacted - #109

Merged
rizukirr merged 3 commits into
mainfrom
feat/send-dry-run
Nov 14, 2026
Merged

rizukirr merged 3 commits into
mainfrom
feat/send-dry-run

Conversation

@rizukirr

Copy link
Copy Markdown
Owner

Adds apic send --dry-run. It prints the request send would build and sends nothing. Every variable that has a value is shown as $name instead of its value, so agents and logs can see what will hit the server without seeing secrets from .apic/env/*.local.toml.

$ apic send -f auth/login --env dev --dry-run
Target: https://api.example.com
POST $baseUrl/auth/login
Authorization: Bearer $token
Content-Type: application/json

{
  "email": "$email",
  "password": "$password"
}

Behaviour

  • Redaction applies everywhere: URL, path params, query, headers, JSON body and multipart parts. There is no flag to reveal values.
  • Target: is the real scheme, host and port, with any user:pass@ removed.
  • The dry run refuses wherever send would, with the same message: an unfilled {id}, a non-http URL, or a missing file part.
  • Headers come out in prepare's order. A Content-Type that prepare adds itself shows its real value.
  • Multipart parts are listed one per line. File parts show their path, filename, content type and size, never their bytes.
  • Each undefined variable gets a warning on stderr. --json prints {"dry_run": true, "method", "target", "url", "headers", "body", "undefined"}, plus parts for a multipart body.
  • --dry-run conflicts with -i. A dry run exits 0, 1, 2 or 3 as send does, and never 4.

Implementation

apic-core gains http::preview and its types Preview, PreviewBody and PartPreview. It calls prepare for the refusals and the real target, then rebuilds the URL, headers and body with each defined name mapped to $name. The URL, query and header steps of prepare moved into private helpers that both functions use, and prepare's output is unchanged.

Tests

  • 5 core tests: redaction, which checks that a secret never appears in the Preview debug output; header parity with prepare; parts without bytes; refusals matching prepare; and undefined-name collection.
  • 5 CLI tests: JSON with no secret on stdout or stderr, the text output, the undefined warning, --dry-run -i, and an unfilled path param.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test and cargo test -p apic-core all pass.

Note

A value written ${tok}x previews as $tokx.

Docs: SENDING.md (new "Dry run" section) and COMMAND.md. The apic-web mirror is a separate PR.

@rizukirr
rizukirr merged commit e9cef8c into main Nov 14, 2026
5 checks passed
@rizukirr
rizukirr deleted the feat/send-dry-run branch November 17, 2026 04:07
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.

1 participant