Skip to content

Render Cloud query errors and add organization context - #369

Open
sdairs wants to merge 2 commits into
issue-331-integer-json-fieldsfrom
issue-334-cloud-error-rendering
Open

Render Cloud query errors and add organization context#369
sdairs wants to merge 2 commits into
issue-331-integer-json-fieldsfrom
issue-334-cloud-error-rendering

Conversation

@sdairs

@sdairs sdairs commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Render documented Query API envelopes as SQL error <code>: <details>.
  • Preserve HTTP status and raw response bodies for malformed, non-JSON, and alternate Query API errors.
  • Add organization scope to bare NOT_FOUND errors while preserving detailed resource errors and existing error kinds/exit codes.

Tests

  • cargo test -p clickhouse-cloud-api --test run_query_test
  • cargo test -p clickhousectl -p clickhouse-cloud-api
  • cargo clippy -p clickhousectl -p clickhouse-cloud-api --all-targets -- -D warnings
  • cargo fmt --all --check

Closes #334

@sdairs
sdairs requested review from iskakaushik and rndD as code owners August 5, 2026 13:04
@sdairs
sdairs temporarily deployed to cloud-integration August 5, 2026 13:04 — with GitHub Actions Inactive
@sdairs sdairs changed the title Render cloud API errors with context (#334) Render Cloud query errors and add organization context Aug 5, 2026
@sdairs
sdairs force-pushed the issue-334-cloud-error-rendering branch from b153814 to decc54c Compare August 5, 2026 13:42
@sdairs
sdairs had a problem deploying to cloud-integration August 5, 2026 13:42 — with GitHub Actions Failure
@sdairs
sdairs requested a review from Copilot August 5, 2026 16:22

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 improves ClickHouse Cloud error rendering in both the clickhousectl CLI and the underlying clickhouse-cloud-api library, addressing issue #334 by making Query API failures human-readable and by adding missing organization context to otherwise ambiguous NOT_FOUND errors.

Changes:

  • Format documented Query API SQL error envelopes as SQL error <code>: <details> while preserving HTTP status + raw body for malformed/non-JSON responses.
  • Add organization request-scope context to bare NOT_FOUND API errors without changing existing error kinds/exit codes.
  • Add regression tests in both the API crate and the CLI crate to pin the new error formatting behavior.

Reviewed changes

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

Show a summary per file
File Description
crates/clickhousectl/tests/cli_request_shape_test.rs Adds CLI-level regression tests for org-scoped NOT_FOUND and Query API error formatting.
crates/clickhousectl/src/cloud/service_query.rs Ensures org-scoped error conversion is used during query endpoint binding.
crates/clickhousectl/src/cloud/postgres.rs Routes Postgres cloud endpoint errors through org-aware error conversion.
crates/clickhousectl/src/cloud/client.rs Introduces org-aware error conversion (convert_error_for_organization) and wires it through org-scoped CloudClient calls.
crates/clickhouse-cloud-api/tests/run_query_test.rs Updates/adds API-level tests to assert new Query API error message formatting and status preservation.
crates/clickhouse-cloud-api/src/client.rs Implements query_api_error_message() and uses it to consistently format Query API errors (including 206 cases).

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

Comment thread crates/clickhousectl/src/cloud/client.rs
@sdairs
sdairs had a problem deploying to cloud-integration August 5, 2026 17:48 — with GitHub Actions Failure
@sdairs
sdairs had a problem deploying to cloud-integration August 5, 2026 17:57 — with GitHub Actions Failure
@sdairs
sdairs force-pushed the issue-334-cloud-error-rendering branch from 8e377f3 to cdb2b4c Compare August 5, 2026 18:28
@sdairs
sdairs had a problem deploying to cloud-integration August 5, 2026 18:28 — with GitHub Actions Failure
@sdairs
sdairs deployed to cloud-integration August 5, 2026 18:55 — with GitHub Actions Active
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 error rendering: Query API errors print as raw JSON blob; wrong --org-id yields bare "Error: NOT_FOUND"

2 participants