Skip to content

Resolve OpenAPI drift: slow query patterns, Postgres metrics, RPE update (#224)#273

Merged
sdairs merged 3 commits into
mainfrom
issue-224-openapi-drift
Jul 6, 2026
Merged

Resolve OpenAPI drift: slow query patterns, Postgres metrics, RPE update (#224)#273
sdairs merged 3 commits into
mainfrom
issue-224-openapi-drift

Conversation

@sdairs

@sdairs sdairs commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Resolves #224.

Issue #224 was auto-filed by the daily drift check against an older live spec. Since then the spec drifted further (and two of #224's items — the CustomPrivateDnsMapping type and the customPrivateDnsMappings fields — were already fixed in a prior PR). This PR clears the full current drift so the daily check goes green and #224 closes cleanly. Library-only, per CLAUDE.md; the only CLI changes are construction sites that wouldn't otherwise compile.

clickhouse-cloud-api

5 client methods (client.rs)

  • slow_query_patterns_get_list, slow_query_pattern_get — Postgres slow query patterns (Beta)
  • postgres_instance_metrics_get — Postgres metrics (Beta)
  • service_clickhouse_setting_delete — delete a ClickHouse setting (Beta)
  • click_pipe_reverse_private_endpoint_update — PATCH a reverse private endpoint

9 model types (models.rs)

  • PostgresSlowQueryPattern, PostgresQueryExecution, PostgresSlowQueryPatternDetail
  • PostgresMetrics, PostgresMetric, PostgresMetricSeries, PostgresMetricDataPoint
  • License, UpdateReversePrivateEndpoint

12 added struct fieldsexactlyOnce, skipCertVerification, disableTls across ClickPipe source structs; name on PostgresServicePatchRequest. Optionality resolved per spec (required array + Optional-description heuristic).

2 removed fieldsseekSnapshot dropped upstream from ClickPipePostPubSubSource / ClickPipePubSubSource.

1 optionality fixClickPipeMutateDestination.rolesOption<Vec<String>>.

Metadata/tests — 4 newly-Beta ops added to BETA_OPERATIONS; 3 now-stale OPTIONALITY_EXEMPTIONS removed (spec now agrees with the model); vendored OpenAPI snapshot refreshed.

clickhousectl

Request builders updated for the changed struct fields with behaviour-preserving defaults. Exposing the new endpoints/fields as CLI commands/flags is intentionally a separate follow-up.

Verification

  • cargo build (workspace), cargo build -p clickhouse-cloud-api --features deprecated-fields
  • cargo test — full suite passes, including all 8 live-spec coverage tests (--ignored)
  • cargo clippy --all-targets and --all-features — clean
  • python3 scripts/check-openapi-drift.py --dry-run0 across every category

🤖 Generated with Claude Code

…ate (#224)

Issue #224 was filed against an older live spec; since then the spec
drifted further and two of its items were already fixed. This clears the
full current drift so the daily check goes green.

clickhouse-cloud-api:
- Add 5 client methods: slow_query_patterns_get_list, slow_query_pattern_get,
  postgres_instance_metrics_get, service_clickhouse_setting_delete,
  click_pipe_reverse_private_endpoint_update.
- Add 9 model types: PostgresSlowQueryPattern, PostgresQueryExecution,
  PostgresSlowQueryPatternDetail, PostgresMetrics, PostgresMetric,
  PostgresMetricSeries, PostgresMetricDataPoint, License,
  UpdateReversePrivateEndpoint.
- Add 12 newly-spec'd struct fields (exactlyOnce, skipCertVerification,
  disableTls across ClickPipe source structs; name on
  PostgresServicePatchRequest).
- Remove 2 fields dropped upstream (seekSnapshot on PubSub sources).
- Flip ClickPipeMutateDestination.roles to Option<Vec<String>> to match spec.
- Add the 4 newly-Beta operations to BETA_OPERATIONS.
- Drop 3 now-stale OPTIONALITY_EXEMPTIONS (spec now agrees with the model).
- Refresh the vendored OpenAPI snapshot.

clickhousectl:
- Update request builders for the changed struct fields (behaviour-preserving
  defaults; CLI flag exposure of the new fields is a separate follow-up).

check-openapi-drift.py --dry-run now reports zero across every category.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sdairs
sdairs requested a review from iskakaushik as a code owner June 25, 2026 21:45
@sdairs
sdairs temporarily deployed to cloud-integration June 25, 2026 21:45 — with GitHub Actions Inactive

@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 default 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 0bdbb2f. Configure here.

Comment thread crates/clickhouse-cloud-api/src/models.rs
The spec dropped `seekSnapshot` and removed `snapshot` from the PubSub
seekType enum (now latest/earliest/timestamp). The field removal landed
in this PR but the Snapshot variant was left on
ClickPipePostPubSubSourceSeektype / ClickPipePubSubSourceSeektype, where
it serialized to "snapshot" — a value the API now rejects.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Read Replica phase of cloud_postgres_crud_lifecycle raced the
primary's first backup: replica create was rejected with a
"no backups, yet" 400, or the replica never reached running within
the steady-state timeout. The test only needs to prove the API surface
works, not that provisioning completes.

- Wrap replica create in retry_api_call, retrying the specific
  "no backups" / "not ready for read replicas" 400 until the
  primary's first backup lands.
- Drop the wait-for-replica-running poll and the hard asserts on
  hostname/connection_string that rode on it.
- Assert create response shape (isPrimary=false, name, non-empty
  state) instead, and keep the list/get visibility checks which work
  in any state.
- Add retry_api_call helper to test infra for transient-error retries.

@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 ce9d249 into main Jul 6, 2026
5 checks passed
@sdairs
sdairs deleted the issue-224-openapi-drift branch July 6, 2026 20:38
sdairs added a commit that referenced this pull request Jul 15, 2026
Neither check-openapi-drift.py nor spec_coverage_test.rs compared the
values of spec enum arrays against Rust enum variants, so a value added
to or removed from a spec enum was invisible to both (the #273 PubSub
seekType/"snapshot" incident).

Add enum value coverage to both, kept in lockstep like the field checks:

- spec -> code (enum_values_cover_every_spec_enum): every spec enum
  value has a matching Rust variant; also flags spec enum locations
  whose Rust type is not a value enum.
- code -> spec (enum_values_have_no_extras_vs_spec): every Rust variant
  serializes a value the spec enum lists.

The spec-to-Rust mapping is structural, not comment-based: inline
property enums resolve through the struct field's declared type (the
actual serialization path) and named enum schemas via
pascalize_identifier. Wire values come from #[serde(rename)] (falling
back to the variant identifier); the untagged catch-all is excluded by
attribute, never by name; oneOf union enums are excluded by shape.
EXTRA_ENUM_VALUE_EXEMPTIONS (empty, stale-checked) mirrors
EXTRA_FIELD_EXEMPTIONS and is parsed by the drift script.

Reconcile the drift the new checks surfaced in models.rs:
- add europe-west2 to 8 region enums, GCP_PSC_SERVICE_ATTACHMENT to
  both reverse-private-endpoint type enums, 6 new threshold types to
  the 3 ClickStack alert enums, and duration to
  ClickStackNumberFormatOutput (with Display arms)
- regenerate PgSize from the spec: 66 stale instance sizes removed,
  default moved from removed c6gd.medium to c6gd.large (breaking)

Closes #275

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Flaky postgres integration test: read replica phase races the primary's first backup OpenAPI drift: 16 gaps between live spec and library

2 participants