Skip to content

Make @hyperdx/common-utils forward-compatible with @clickhouse/client 1.23#2500

Merged
kodiakhq[bot] merged 4 commits into
mainfrom
copilot/forward-compatible-clickhouse-client
Jun 24, 2026
Merged

Make @hyperdx/common-utils forward-compatible with @clickhouse/client 1.23#2500
kodiakhq[bot] merged 4 commits into
mainfrom
copilot/forward-compatible-clickhouse-client

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Discovered in:

In @clickhouse/client* 1.23, @clickhouse/client-common is deprecated: @clickhouse/client (Node) and @clickhouse/client-web (Web) no longer depend on it — each now bundles and re-exports its own copy of the shared types. This repo imported types from client-common but got its runtime from the platform packages, so under 1.23 the two same-named ClickHouseSettings aliases become distinct nominal types (their index signature references a private-membered SettingsMap class), breaking the common-utils declaration build and cascading into every downstream job.

This change repoints imports so each file's ClickHouse types come from the same platform package as its runtime, making the repo compile against both the current pin and 1.23. No @clickhouse/client* version bumps — the actual upgrade can land later with no further code changes.

  • Type imports → platform package
    • clickhouse/browser.ts (web runtime) → @clickhouse/client-web
    • clickhouse/node.ts (node runtime) → @clickhouse/client
    • __tests__/clickhouse.test.ts, metadata.int.test.ts, queryChartConfig.int.test.ts@clickhouse/client (matches the client they instantiate; also clears the clientClickHouseSettings private-property errors)
    • packages/cli/src/api/client.ts@clickhouse/client; dropped the now-unused @clickhouse/client-common dep from cli package.json
  • Intentionally retained on client-commonclickhouse/index.ts and core/metadata.ts. These are cross-platform/barrel modules, and ResponseHeaders is not re-exported by the platform packages at the pinned 1.12.1, so migrating them would break the current build. This is the only remaining (justified) client-common usage.
  • Shared base-class bridge — import swaps alone don't suffice for 1.23: BaseClickhouseClient feeds one platform-neutral settings object into both a WebClickHouseClient | NodeClickHouseClient union and both subclasses, whose settings types diverge under 1.23. Bridged with a single typed getClient() override per subclass plus a neutral→platform cast on processClickhouseSettings() — type-only, following the file's existing // client library type mismatch convention.
// node.ts — subclass narrows the base class's platform-agnostic client once
protected getClient(): NodeClickHouseClient {
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- subclass always builds a node client
  return super.getClient() as NodeClickHouseClient;
}

The only lockfile delta is the cli client-common removal; no version entries change.

Screenshots or video

N/A — non-UI change.

How to test on Vercel preview

N/A — non-UI change.

References

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5f317f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@hyperdx/common-utils Patch
@hyperdx/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment Jun 24, 2026 11:02am
hyperdx-storybook Ready Ready Preview, Comment Jun 24, 2026 11:02am

Request Review

@greptile-apps

greptile-apps Bot commented Jun 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes @hyperdx/common-utils and @hyperdx/cli forward-compatible with @clickhouse/client* 1.23 by repointing type imports away from the deprecated @clickhouse/client-common to the platform-specific packages (@clickhouse/client for Node, @clickhouse/client-web for browser). Two additional 1.23-compat patterns — a getClient() narrowing override and a processClickhouseSettings() return-value cast — are introduced in node.ts and browser.ts to handle the type divergence when each platform package bundles its own copy of shared types.

  • node.ts / browser.ts: Type imports migrated to their respective platform packages; getClient() narrowing and as ClickHouseSettings cast added following the existing // client library type mismatch convention.
  • Test files: ClickHouseClient and ResponseJSON imports moved from @clickhouse/client-common to @clickhouse/client, matching the Node runtime they instantiate.
  • packages/cli: Type imports in client.ts updated; @clickhouse/client-common devDependency dropped from package.json. However, ProxyClickhouseClient is still missing the getClient() narrowing override and the processClickhouseSettings() cast that node.ts received — it will hit the same 1.23 compile error this PR is meant to prevent.

Confidence Score: 4/5

The core forward-compat work in node.ts and browser.ts is correct and well-structured, but ProxyClickhouseClient in the CLI package was not fully migrated and will still fail to compile under @clickhouse/client 1.23.

The two 1.23-compat patterns introduced in node.ts (getClient() narrowing + processClickhouseSettings() cast) were not carried over to ProxyClickhouseClient in packages/cli/src/api/client.ts, which creates a Node client the same way. Without those two changes, the CLI's ClickHouse client will produce the same type errors under 1.23 that this PR is designed to eliminate.

packages/cli/src/api/client.ts — ProxyClickhouseClient needs a getClient() narrowing override and an as ClickHouseSettings cast on the processClickhouseSettings() return value.

Important Files Changed

Filename Overview
packages/cli/src/api/client.ts Import updated from @clickhouse/client-common to @clickhouse/client, but ProxyClickhouseClient is still missing both 1.23 forward-compat patterns (getClient() narrowing override and processClickhouseSettings() cast) that were applied to the analogous node.ts class.
packages/common-utils/src/clickhouse/node.ts Imports types from @clickhouse/client instead of @clickhouse/client-common; adds getClient() narrowing and processClickhouseSettings() cast for 1.23 forward-compat.
packages/common-utils/src/clickhouse/browser.ts Imports types from @clickhouse/client-web; adds getClient() narrowing and processClickhouseSettings() cast mirroring node.ts; all patterns correctly applied.
packages/cli/package.json Removes @clickhouse/client-common devDependency, which is no longer needed after the import migration in cli/src/api/client.ts.
packages/common-utils/src/tests/clickhouse.test.ts ResponseJSON import moved from @clickhouse/client-common to @clickhouse/client to match the Node runtime package used in tests.
packages/common-utils/src/tests/metadata.int.test.ts ClickHouseClient type import moved from @clickhouse/client-common to @clickhouse/client, consistent with the createClient runtime already imported from @clickhouse/client.
packages/common-utils/src/tests/queryChartConfig.int.test.ts ClickHouseClient type import moved from @clickhouse/client-common to @clickhouse/client; symmetric change with metadata.int.test.ts.
.changeset/clickhouse-client-forward-compat.md Adds patch-level changeset entry for @hyperdx/common-utils and @hyperdx/cli documenting the type import migration.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class BaseClickhouseClient {
        +client: WebClickHouseClient | NodeClickHouseClient
        +processClickhouseSettings() ClickHouseSettings [from client-common]
        +getClient() WebClickHouseClient | NodeClickHouseClient
        +query()
    }

    class ClickhouseClient_node {
        +getClient() NodeClickHouseClient [NEW override]
        +__query() cast processClickhouseSettings as NodeClickHouseSettings
    }

    class ClickhouseClient_browser {
        +getClient() WebClickHouseClient [NEW override]
        +__query() cast processClickhouseSettings as WebClickHouseSettings
    }

    class ProxyClickhouseClient {
        +createClient from @clickhouse/client
        +__query() MISSING getClient() override
        +__query() MISSING processClickhouseSettings cast
    }

    BaseClickhouseClient <|-- ClickhouseClient_node : extends node.ts
    BaseClickhouseClient <|-- ClickhouseClient_browser : extends browser.ts
    BaseClickhouseClient <|-- ProxyClickhouseClient : extends cli/client.ts
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
classDiagram
    class BaseClickhouseClient {
        +client: WebClickHouseClient | NodeClickHouseClient
        +processClickhouseSettings() ClickHouseSettings [from client-common]
        +getClient() WebClickHouseClient | NodeClickHouseClient
        +query()
    }

    class ClickhouseClient_node {
        +getClient() NodeClickHouseClient [NEW override]
        +__query() cast processClickhouseSettings as NodeClickHouseSettings
    }

    class ClickhouseClient_browser {
        +getClient() WebClickHouseClient [NEW override]
        +__query() cast processClickhouseSettings as WebClickHouseSettings
    }

    class ProxyClickhouseClient {
        +createClient from @clickhouse/client
        +__query() MISSING getClient() override
        +__query() MISSING processClickhouseSettings cast
    }

    BaseClickhouseClient <|-- ClickhouseClient_node : extends node.ts
    BaseClickhouseClient <|-- ClickhouseClient_browser : extends browser.ts
    BaseClickhouseClient <|-- ProxyClickhouseClient : extends cli/client.ts
Loading

Comments Outside Diff (1)

  1. packages/cli/src/api/client.ts, line 348-388 (link)

    P1 ProxyClickhouseClient missing both 1.23 forward-compat fixes

    ProxyClickhouseClient always creates a Node client (line 327) but is missing the two patterns this PR introduces in node.ts:

    1. No processClickhouseSettings() cast — the base class method (index.ts) returns Promise<ClickHouseSettings> where ClickHouseSettings resolves from @clickhouse/client-common. Here clickhouseSettings is declared as ClickHouseSettings from @clickhouse/client. Under 1.23 these become distinct nominal types, making the assignment at line 360 a compile error without an as ClickHouseSettings cast (same fix applied at node.ts lines 56–59).

    2. No getClient() narrowing overridethis.getClient() returns the base class's WebClickHouseClient | NodeClickHouseClient union. Under 1.23, calling .query() on the union whose members have diverged ClickHouseSettings types would be a compile error at line 380 (same fix applied at node.ts lines 33–36).

    The import change on line 14 is the right first step, but without the cast and the narrowing override, this class will hit the same build failure under 1.23 that the PR is trying to prevent.

    Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

Fix All in Claude Code Fix All in Conductor Fix All in Cursor Fix All in Codex

Reviews (3): Last reviewed commit: "Merge branch 'main' into copilot/forward..." | Re-trigger Greptile

@peter-leonov-ch

Copy link
Copy Markdown

hat class will still produce the same nominal-type compile errors under 1.23 that motivated the PR, meaning the 1.23 bump will still require a follow-up fix to client.ts before CI passes.

The coding agent session tested the changes in this PR against the 1.23 here: https://github.com/hyperdxio/hyperdx/sessions/09fe9533-5802-414b-892d-0b6f057a7c20

If that's actually the case, I'll iterate on it until the gating PR turns green.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 218 passed • 3 skipped • 1500s

Status Count
✅ Passed 218
❌ Failed 0
⚠️ Flaky 4
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

@peter-leonov-ch peter-leonov-ch marked this pull request as ready for review June 22, 2026 23:21
@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 4
  • Production lines changed: 37 (+ 6 in test files, excluded from tier calculation)
  • Branch: copilot/forward-compatible-clickhouse-client
  • Author: Copilot

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@wrn14897 wrn14897 self-requested a review June 23, 2026 18:46

@wrn14897 wrn14897 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

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 updates HyperDX’s ClickHouse client type imports so @hyperdx/common-utils (and the CLI) remain compatible with both the currently pinned @clickhouse/client* and the newer 1.23+ packaging where @clickhouse/client-common is deprecated and type identity can diverge.

Changes:

  • Swap ClickHouse type imports to come from the same platform package as the runtime client (@clickhouse/client for node/tests/cli, @clickhouse/client-web for browser).
  • Add subclass getClient() narrowing in the node/browser common-utils clients to avoid Web|Node union type issues.
  • Remove @clickhouse/client-common from the CLI package and add a changeset for patch releases.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Drops @clickhouse/client-common from the CLI workspace lock entry.
packages/common-utils/src/clickhouse/node.ts Moves CH types to @clickhouse/client and adds node-specific getClient() narrowing + settings cast.
packages/common-utils/src/clickhouse/browser.ts Moves CH types to @clickhouse/client-web and adds web-specific getClient() narrowing + settings cast.
packages/common-utils/src/tests/queryChartConfig.int.test.ts Updates ClickHouseClient import to @clickhouse/client.
packages/common-utils/src/tests/metadata.int.test.ts Updates ClickHouseClient import to @clickhouse/client.
packages/common-utils/src/tests/clickhouse.test.ts Updates ResponseJSON import to @clickhouse/client.
packages/cli/src/api/client.ts Updates CH type imports to @clickhouse/client.
packages/cli/package.json Removes @clickhouse/client-common devDependency.
.changeset/clickhouse-client-forward-compat.md Adds patch changeset for @hyperdx/common-utils and @hyperdx/cli.

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

Comment on lines +56 to +59
clickhouseSettings = (await this.processClickhouseSettings({
externalClickhouseSettings,
connectionId,
});
})) as ClickHouseSettings;
Comment on lines +138 to +141
clickhouseSettings = (await this.processClickhouseSettings({
connectionId,
externalClickhouseSettings,
});
})) as ClickHouseSettings;
Comment on lines 11 to +15
import type {
BaseResultSet,
ClickHouseSettings,
DataFormat,
} from '@clickhouse/client-common';
} from '@clickhouse/client';
@kodiakhq kodiakhq Bot merged commit 45954c3 into main Jun 24, 2026
20 checks passed
@kodiakhq kodiakhq Bot deleted the copilot/forward-compatible-clickhouse-client branch June 24, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants