{{ message }}
feat(ch-cloud): ClickHouse Cloud connect preset + optional billing usage sync (plan 41) - #2240
Merged
Merged
Conversation
Add a "Self-hosted / ClickHouse Cloud" connection-type selector to ConnectionForm. Selecting Cloud sets host-field placeholder/hint text for the Cloud hostname pattern, defaults username to "default" when empty, and normalizes a pasted host on blur to https + port 8443 (the HTTPS interface ClickHouse Cloud requires) so a Cloud service connects on the first try. The connection model stores a single `host` URL string (no separate secure/port fields), so the preset works by normalizing that string rather than toggling fields. An explicit http:// choice is never silently rewritten — instead the Test Connection error panel gets a Cloud-specific TLS/port hint when the preset is active. Self-host behavior and the existing SSRF-guarded test/create routes are unchanged. Co-Authored-By: duyetbot <bot@duyet.net>
New src/lib/ch-cloud/billing-sync.ts, off by default. Only runs when both CHM_FEATURE_CLOUD_BILLING_SYNC and full API credentials (CLICKHOUSE_CLOUD_API_KEY_ID/_SECRET/_ORG_ID) are configured; otherwise a true no-op (no network call, no data, no placeholder numbers). When configured, fetches organization usage/cost from the ClickHouse Cloud API through the same SSRF-guarded fetch the add-host wizard uses (createHostValidationFetch/validateHostUrl) rather than opening a second, unguarded outbound path, and caches successful results for an hour via the shared in-memory cache. Two things deliberately left for a follow-up once a real consumer exists (no cost-card UI or cost-aware alerts exist in this codebase yet): the response is returned as `unknown` rather than parsed into named cost fields, and the auth format (HTTP Basic, key id/secret) was not independently re-verified against ClickHouse's current API reference. Also note the guarded fetch's DNS-pinning needs Node's `node:dns`, so this sync only runs end-to-end under Node.js (self-hosted); on the Cloudflare Workers runtime it fails closed with a reported error, never a crash. Co-Authored-By: duyetbot <bot@duyet.net>
Contributor
bun 1.3.13's lcov coverage writer intermittently throws "error: An internal error occurred (WriteFailed)" after all tests have already passed. Reproduced deterministically in CI on both main and this PR (all 5000+ tests pass, then the coverage writer step fails); a local run against bun 1.3.14 is clean. Bump the unit-tests job's pinned bun-version to 1.3.14. Co-Authored-By: duyetbot <bot@duyet.net>
Contributor
☁️ Cloudflare Preview Deployment
|
duyet
enabled auto-merge (squash)
July 3, 2026 17:48
Contributor
☁️ Cloudflare Preview Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What (plan 41 — ClickHouse Cloud connect wizard)
connection-presets.ts+connection-form.tsx) — additive; the manual add-host flow is untouched and the SSRF/host-validation guard is preserved.lib/ch-cloud/billing-sync.ts), fail-open without config.bun run check+depcruiseclean.🔶 Held for review
Touches the connection form (SSRF-adjacent surface) and adds a billing-usage sync. Also overlaps held #2225 (plan 66)'s add-host dialog — reconcile at merge. Docs were the only unfinished piece (agent stalled before the docs step); code + tests are complete.
Co-Authored-By: duyetbot bot@duyet.net