Skip to content

Repair stale stored query keys - #508

Closed
sdairs wants to merge 10 commits into
issue-453-query-endpoint-readinessfrom
issue-454-repair-query-key
Closed

Repair stale stored query keys#508
sdairs wants to merge 10 commits into
issue-453-query-endpoint-readinessfrom
issue-454-repair-query-key

Conversation

@sdairs

@sdairs sdairs commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add explicit cloud service query --repair-query-key replacement for one stored service credential
  • turn stored-key Query API 401/403 responses into actionable, non-mutating repair guidance
  • require exact saved organization, management key, endpoint, and binding ownership before repair
  • replace only the owned endpoint key UUID while preserving other endpoint keys, roles, origins, project API credentials, and service credentials
  • retain the inherited provisioning lock, atomic credential write, rollback on persistence failure, and newly provisioned endpoint readiness retry
  • refuse legacy or missing records instead of guessing or silently provisioning

Tests

  • cargo test -p clickhousectl
  • cargo test -p clickhousectl --test cli_request_shape_test service_query_repair_replaces_only_the_exact_owned_key_and_binding -- --exact
  • cargo test -p clickhousectl cloud::services::tests::parses_service_query
  • cargo fmt --all --check
  • cargo clippy -p clickhousectl --all-targets -- -D warnings

Subprocess coverage pins stored-key 401 and 403 guidance with no writes, exact binding replacement when the old management key is already absent, unrelated credential preservation, and safe legacy-record refusal.

Stack

This is the child of issue-453-query-endpoint-readiness (PR #504) in gh-stack #505. It targets the parent branch; PR #504 should merge first.

Closes #454

Stack created with GitHub Stacks CLIGive Feedback

Comment thread crates/clickhousectl/src/cloud/service_query.rs Outdated
Comment thread crates/clickhousectl/src/cloud/service_query.rs Outdated
Comment thread crates/clickhousectl/src/cloud/service_query.rs Outdated
Comment thread crates/clickhousectl/src/cloud/service_query.rs Outdated
@sdairs
sdairs force-pushed the issue-453-query-endpoint-readiness branch from 75e8a6c to f970de0 Compare August 25, 2026 12:11
@sdairs
sdairs force-pushed the issue-454-repair-query-key branch from d1598a0 to 1ccc501 Compare August 25, 2026 12:11
Comment thread crates/clickhousectl/src/cloud/service_query.rs Outdated
Comment thread crates/clickhousectl/src/cloud/service_query.rs Outdated
Comment thread crates/clickhousectl/src/cloud/service_query.rs
@sdairs

sdairs commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

This is over-engineered. The ability to create a key and associated it to a QE is already possible. This should simply be described in the output when it occurs, baking the functionality into another flag is uncessary.

@sdairs

sdairs commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed in 6cc7dc3: removed the dedicated --repair-query-key flag and rotation implementation. Stored-key 401/403 handling remains non-mutating and now explains how to create a key and associate its key.id through the existing query-endpoint get/create commands, including the full-configuration replacement warning. Existing automatic first-use provisioning and readiness behavior is unchanged.

Verified with:

  • cargo test -p clickhousectl cloud::services::tests::service_query_help_describes_input_source_conflict -- --exact
  • cargo test -p clickhousectl --test cli_request_shape_test stale_stored_query_key_guidance_uses_existing_key_and_endpoint_commands -- --exact
  • cargo fmt --all --check
  • cargo check -p clickhousectl
  • cargo clippy -p clickhousectl --all-targets -- -D warnings

Comment thread crates/clickhousectl/src/cloud/services.rs Outdated
Comment thread crates/clickhousectl/src/cloud/services.rs Outdated
Comment thread crates/clickhousectl/src/cloud/services.rs Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9e6095c. Configure here.

Comment thread crates/clickhousectl/src/cloud/services.rs

@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 force-pushed the issue-453-query-endpoint-readiness branch from 6d78b4f to e5ca8db Compare August 25, 2026 21:44
@sdairs

sdairs commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #538 in stack #563.

@sdairs sdairs closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-cloud-integration Run live Cloud integration tests for this PR head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a service-scoped repair path for stale stored query keys

2 participants