Skip to content

Fix cloud postgres delete --json returning raw API envelope - #624

Merged
sdairs merged 2 commits into
fix/613-postgres-usage-exit-codesfrom
fix/614-postgres-delete-json
Sep 3, 2026
Merged

Fix cloud postgres delete --json returning raw API envelope#624
sdairs merged 2 commits into
fix/613-postgres-usage-exit-codesfrom
fix/614-postgres-delete-json

Conversation

@sdairs

@sdairs sdairs commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • cloud postgres delete --json was printing the raw API envelope ({"status":200,"requestId":"..."}) returned directly by the delete endpoint, instead of the Postgres resource object every other cloud postgres subcommand emits under --json.
  • The delete endpoint's response body genuinely has no resource in result (it's ApiResponse<serde_json::Value>), so the fix fetches the service via postgres_service_get before issuing the delete, and renders that fetched object under --json. Human output (Postgres service <id> deletion initiated) was already not envelope-shaped, so it is unchanged.
  • Note: cloud service delete --json has the same underlying envelope shape (its DeleteResponse wrapper only carries status/requestId), but that's out of scope for this issue, which is specifically about cloud postgres delete.

This PR is part of a stacked chain based on fix/613-postgres-usage-exit-codes (not main).

Test plan

  • Added postgres_delete_json_emits_the_resource_object_not_the_envelope wiremock subprocess test in crates/clickhousectl/tests/cli_request_shape_test.rs, asserting the resource fields are present and status/requestId are absent from --json output.
  • cargo fmt --all
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test -p clickhousectl (all passing)

Fixes #614

🤖 Generated with Claude Code

@sdairs
sdairs force-pushed the fix/614-postgres-delete-json branch from 23609f5 to c6c4c70 Compare August 28, 2026 14:46
@sdairs
sdairs force-pushed the fix/614-postgres-delete-json branch 2 times, most recently from 03b5afb to b6daf73 Compare September 1, 2026 15:05
sdairs and others added 2 commits September 1, 2026 21:26
…raw envelope

The delete endpoint only ever returns the raw API envelope
({"status":...,"requestId":...}); fetch the Postgres service before
deleting it and render that instead, matching every other `cloud
postgres` subcommand's --json shape.

Fixes #614

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The pre-delete GET added for #614 called `client.api().postgres_service_get`
directly, copying the pre-modularization pattern CLAUDE.md asks new code
not to copy. Add a thin `CloudClient::get_postgres_service` wrapper in the
module's `impl CloudClient` block (same shape as `get_service` in
services.rs) and use it from the delete handler.

The two post-delete result lines also used `println!`; by then the DELETE
has already succeeded, so a closed stdout would turn a completed deletion
into a panic (exit 101, the #598 class). Emit them with `print_line`,
exactly as `service delete` does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@iskakaushik iskakaushik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@sdairs
sdairs merged commit 0e5a434 into main Sep 3, 2026
10 checks passed
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.

cloud postgres delete --json returns raw API envelope instead of resource object

2 participants