Skip to content

fix: route all HTTP clients through --debug transport logger - #81

Merged
jpage-godaddy merged 4 commits into
rust-portfrom
hook-up-debug
Jul 7, 2026
Merged

jpage-godaddy merged 4 commits into
rust-portfrom
hook-up-debug

Conversation

@jpage-godaddy

Copy link
Copy Markdown
Collaborator

Summary

  • --debug transport only worked for commands going through cli-engine's own HttpClient. Every raw reqwest::Client call site in this crate (ApplicationClient, HostingClient, the api call explorer command, webhook events) and in domains-client built and sent requests directly, so nothing was logged for them.
  • Split each send into an explicit build() → debug_log_reqwest_request() → execute() → capture status/headers before consuming the body → debug_log_reqwest_response(), then continue with the existing error/parsing logic unchanged.
  • domains-client is fixed via a ClientHooks impl (progenitor's sanctioned extension point) rather than touching generated code.

Test plan

  • cargo check — clean
  • cargo clippy -- -D warnings — clean
  • cargo fmt --check — clean
  • cargo test --workspace — 235 passed, 0 failed (including a new domains-client test asserting the hooks fire on a mocked call)
  • Manually confirmed gddy domain purchase ... --debug transport now emits HTTP request/response logs

🤖 Generated with Claude Code

domains-client, ApplicationClient, HostingClient, the `api call` explorer
command, and `webhook events` all built and sent reqwest requests directly,
bypassing cli-engine's transport debug logger. Split each send into an
explicit build()/execute() so debug_log_reqwest_request/response can bridge
into the --debug transport output, matching the behavior every other CLI
command already gets for free.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes --debug transport consistently log HTTP traffic across the CLI by routing previously “raw” reqwest::Client call sites through cli-engine’s reqwest request/response logging hooks, including the progenitor-generated domains-client via ClientHooks.

Changes:

  • Refactors multiple request send paths to build() → debug_log_reqwest_request() → execute() → read body/status/headers → debug_log_reqwest_response().
  • Updates JSON/error parsing to operate on captured response bytes/text while preserving existing control flow.
  • Adds a domains-client ClientHooks implementation plus a test asserting the bridge fires, and adds the cli-engine dependency to domains-client.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rust/src/webhook/mod.rs Logs webhook event-type HTTP request/response via reqwest build/execute path.
rust/src/hosting/nodejs/client.rs Logs HostingClient requests/responses and preserves existing JSON/error handling.
rust/src/application/client.rs Logs ApplicationClient GraphQL + artifact upload requests/responses via captured bytes.
rust/src/api_explorer/mod.rs Logs api call explorer requests/responses and parses body from captured bytes.
rust/domains-client/src/lib.rs Implements progenitor ClientHooks bridge to cli-engine transport logger and adds a test.
rust/domains-client/Cargo.toml Adds cli-engine dependency for the transport logging bridge.
rust/Cargo.lock Locks cli-engine as a dependency of domains-client.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/domains-client/src/lib.rs Resolved
Address Copilot review feedback: the debug-transport bridge test set the
process-wide default transport logger and only reset it after the
assertions, so a panicking assertion would leak the test's RecordingLogger
into later tests. Add an RAII guard that restores the noop logger on drop,
plus a test-only mutex to serialize any future tests that touch the same
global, mirroring cli-engine's own internal (crate-private) pattern.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Comment thread rust/src/hosting/nodejs/client.rs Resolved
Comment thread rust/src/application/client.rs Resolved
Address Copilot review feedback on the debug-transport changes:

- HostingClient::send_json/upload_source were logging text.as_bytes() —
  the re-encoded UTF-8 string after reqwest's charset decoding — instead
  of the actual bytes received over the wire. Capture resp.bytes() first
  and log/parse from those, matching the pattern already used elsewhere
  (ApplicationClient, domains-client, webhook, api_explorer).
- On JSON-decode failure, ApplicationClient::query and HostingClient's
  helpers discarded the actual response body, leaving only the serde
  error message. Include the raw body text in the error so a malformed
  response (HTML error page, proxy interstitial, etc.) is debuggable.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Comment thread rust/src/api_explorer/mod.rs Resolved
Address Copilot review feedback: resp.bytes().await.unwrap_or_default()
silently treated a body-read I/O failure (e.g. connection reset,
decompression error) as an empty body, hiding real transport failures.
Propagate the error like build()/execute() already do in this function.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.

@jpage-godaddy
jpage-godaddy merged commit d0c94a3 into rust-port Jul 7, 2026
2 checks passed
@jpage-godaddy
jpage-godaddy deleted the hook-up-debug branch July 7, 2026 22:38
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.

4 participants