Repository navigation
Conversation
Code Review Agent Run #bcf184Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44283 +/- ##
===========================================
+ Coverage 56.66% 85.98% +29.31%
===========================================
Files 3130 3126 -4
Lines 217962 217622 -340
Branches 51682 51526 -156
===========================================
+ Hits 123511 187112 +63601
+ Misses 93255 27088 -66167
- Partials 1196 3422 +2226
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| """ | ||
| # Credentials are not escaped for "@", so the host section starts after the | ||
| # last one. | ||
| host_start = remainder.rfind("@") + 1 |
There was a problem hiding this comment.
Suggestion: rfind("@") scans query and path text too, so an @ after the authority changes the detected host start and corrupts the rewritten URI. [logic error]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/migrations/versions/2026-09-15_00-00_f7b3a9c14e02_migrate_clickhouse_to_clickhousedb.py
**Line:** 123:123
**Comment:**
*Logic Error: `rfind("@")` scans query and path text too, so an `@` after the authority changes the detected host start and corrupts the rewritten URI.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 1218d9d.
The code finds the authority boundary at the first / or ?, then searches for @ only within that authority. Path or query text can no longer affect the credential separator.
If that's not right, unresolve this thread and CodeAnt will leave it open.
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 0f0043b.
The code finds the authority boundary at the first / or ?, then searches for @ only within that authority.
If that's not right, unresolve this thread and CodeAnt will leave it open.
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 0eae123.
The code finds the authority boundary at the first / or ?, then searches for @ only within that authority.
If that's not right, unresolve this thread and CodeAnt will leave it open.
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of eba10e7.
The parser now finds the authority boundary at the first / or ? and searches for @ only within that authority.
If that's not right, unresolve this thread and CodeAnt will leave it open.
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 0127f20.
The parser now finds the authority boundary at the first / or ? and searches for @ only within that authority.
If that's not right, unresolve this thread and CodeAnt will leave it open.
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 6b9ef67.
The parser now finds the authority boundary at the first / or ? and searches for @ only within that authority.
If that's not right, unresolve this thread and CodeAnt will leave it open.
| for database in paginated_update(query): | ||
| updated = _migrate_uri(database.sqlalchemy_uri) | ||
| if updated: | ||
| database.sqlalchemy_uri = updated |
There was a problem hiding this comment.
Suggestion: The rewritten scheme and possibly port add characters to the URI, so rows already at the dbs.sqlalchemy_uri 1024-character limit can fail or be truncated. [type error]
Assessment: 🟠 Major · 🔁 Occurrence: Rarely
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/migrations/versions/2026-09-15_00-00_f7b3a9c14e02_migrate_clickhouse_to_clickhousedb.py
**Line:** 185:185
**Comment:**
*Type Error: The rewritten scheme and possibly port add characters to the URI, so rows already at the `dbs.sqlalchemy_uri` 1024-character limit can fail or be truncated.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 1218d9d.
The migration checks the rewritten URI against the 1024-character column limit and skips the update with a warning when it would exceed that limit.
If that's not right, unresolve this thread and CodeAnt will leave it open.
|
I reproduced the master migration conflict at @eschutho Would you be comfortable separating the baseline repair into a minimal no-op merge revision, with this migration then rebased/reparented to that revision? That would unblock master without coupling the repair to the ClickHouse data rewrite. Neither migration should land unchanged alongside an independent merge of the same parents: that would leave two heads again. No changes have been made to this PR or the driver PRs. |
|
The standalone no-op baseline repair is now ready for review as #44288, revision |
|
Coordination update for @eschutho: @mikebridge has selected #44288, and duplicate #44317 is CLOSED without merging. #44288 remains the fully green standalone baseline repair (13/13 required checks SUCCESS), awaiting your requested maintainer review. After #44288 lands, please rebase/reparent this migration onto Owners of #44284–#44287 are awaiting actual repaired master before rebasing/rerunning all applicable checks. The landing watch will notify them only after verifying the merged repair is on master with a single head. No merge, draft conversion, or code changes to this PR are being made by this session. |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
mikebridge
left a comment
There was a problem hiding this comment.
One migration-graph note below — flagging only the parent pointer; I have not reviewed the ClickHouse migration itself, so this is a comment rather than an approval.
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "f7b3a9c14e02" | ||
| down_revision = ("88a01c781622", "c7f53d184ea2") |
There was a problem hiding this comment.
#44288 landed (4c27cbd007) and consumed both of these parents into e2f3a1b9c640, so master is single-headed again. As written this migration takes the same two parents, which makes it a second childless head — re-forking the graph the moment it merges.
| down_revision = ("88a01c781622", "c7f53d184ea2") | |
| down_revision = "e2f3a1b9c640" |
Worth knowing for anyone tracking the earlier CI breakage: enforce-single-migration-head will catch this here because this PR touches superset/migrations/, but the two-head state is invisible to every PR that does not — it surfaces instead as docker-build (dev) failing on flask db upgrade, which cascades into the whole integration matrix.
mikebridge
left a comment
There was a problem hiding this comment.
Posting on Mike Bridge's behalf — this is their PR reviewer agent. Forward any pushback to them and they'll loop me back in.
Ran six review lenses over this across two different models (four locally, two in a separate Codex session with no shared context). Four things below look worth addressing before merge; I've left out the cosmetic notes. All line numbers verified against aa58f1e8. Separate from my earlier comment about the down_revision parent, which still applies.
superset/config.py:2328 (not in this diff)
DISALLOWED_SQL_FUNCTIONS is keyed by db_engine_spec.engine and read as .get(engine, set()) in three places — superset/sql_lab.py:481, superset/models/helpers.py:2283, superset/commands/sql_lab/estimate.py:107. The dict has a clickhouse key but no clickhousedb one, and ClickHouseConnectEngineSpec.engine = "clickhousedb" (superset/db_engine_specs/clickhouse.py:387). So every row this migration rewrites moves to a key with no entry, and the denylist falls back to the empty set — un-blocking currentUser, hostName, getOSInformation, getSetting, url and filesystemPath at all three gates.
Would it be worth adding the key in this PR, so the guard travels with the rows?
"clickhousedb": DISALLOWED_SQL_FUNCTIONS["clickhouse"],(Can't make that an applyable suggestion since config.py isn't in the diff, sorry.)
superset/migrations/versions/2026-09-15_00-00_f7b3a9c14e02_migrate_clickhouse_to_clickhousedb.py:195
When protocol=https becomes secure=true and the URI carries no explicit port, the effective port looks like it changes. On the target side I executed this against the pinned 1.7.2 rather than inferring it: default_port("http", secure=True) == 8443 and default_port("http", secure=False) == 8123, so the new driver resolves a port-less secure=true row to 8443.
The legacy half I could not run — clickhouse-sqlalchemy isn't installed in my environment — so "the old HTTP dialect defaults to 8123 regardless of protocol" comes from reading its source, not from executing it. You'll know better than me whether that holds. If it does, clickhouse://host/db?protocol=https moves from 8123 to 8443, and the string really is preserved byte-for-byte while the meaning shifts underneath it.
Could we pin :8123 explicitly when the rewrite introduces secure=true and no port is present — the same technique already used for native rows at :169-174?
…f7b3a9c14e02….py:222-228 and tests/unit_tests/migrations/test_migrate_clickhouse_to_clickhousedb.py:176-178
_remap_native_port decides the port at :222-226, but _migrate_query doesn't run until :228, so the port decision can't see the TLS flag. A native row carrying secure=true — preserved untouched per the docstring at :53-54 — ends up asserting TLS against 8123, the plaintext HTTP interface. The engine spec derives this correctly elsewhere via default_port("http", encryption) (superset/db_engine_specs/clickhouse.py:620).
The parametrised case at test :176-178 asserts exactly this output as correct, so the suite currently ratifies it rather than catching it — worth changing in the same pass.
WDYT about deriving the port from the post-_migrate_query secure value, or skipping native+TLS rows the way non-default-port rows already are?
…f7b3a9c14e02….py:200
Every parameter except protocol is carried across verbatim, but the two drivers don't share a vocabulary. The one that looks most likely to bite: the legacy HTTP dialect turns ?endpoint=clickhouse into the HTTP request path, whereas clickhouse-connect builds that from proxy_path and routes unrecognised kwargs into settings, where invalid_setting_action defaults to error. A connection behind a path-prefixed reverse proxy would migrate "successfully" and then stop addressing its route. Same shape for engine_reflection, alt_hosts, and ca_certs (spelled ca_cert in the target).
Could we translate the known-divergent names, or treat an unrecognised parameter as a skip-with-warning rather than a silent carry-over?
One thing that ties these together rather than being separate: with downgrade() a no-op at :260-265, none of the above is recoverable. The reasoning for the no-op is sound as far as it goes — a migrated row is textually indistinguishable from a natively-created one — but that's a consequence of not recording what was rewritten. Stashing (id, original_uri) and restoring only rows still matching the migration's own output would make it exactly reversible. The Databend precedent in-tree does this (2026-08-06_00-00_c4a1b8e2d739_databend_secure_to_sslmode.py:162-163). Worth noting the checklist ticks "supports rollback" against a pass body.
And a genuine question rather than a finding: should this be a migration at all? A schema migration that's wrong gets caught by CI, but this one is only wrong against a particular operator's ClickHouse topology, which CI can't see — whether HTTP is enabled, whether egress allows 8123. A superset CLI command with --dry-run, referenced from UPDATING.md, would keep the destructive step where the topology knowledge is. Entirely your call, and I may be over-weighting the risk.
Worth crediting: mirroring the Databend migration's shape — local shadow model, paginated_update, in-place query editing instead of round-tripping through URL.render_as_string — is the right instinct, and avoids silently reordering unrelated parameters. Skipping rather than guessing on non-default native ports and IPv6 hosts is the same instinct; the finding above is really that the skip list needs to reach the operator.
There was a problem hiding this comment.
Code Review Agent Run #9aaf09
Actionable Suggestions - 1
-
superset/migrations/versions/2026-09-15_00-00_f7b3a9c14e02_migrate_clickhouse_to_clickhousedb.py - 1
- CWE-319: TLS Downgrade · Line 191-201
Additional Suggestions - 2
-
superset/migrations/versions/2026-09-15_00-00_f7b3a9c14e02_migrate_clickhouse_to_clickhousedb.py - 2
-
URI parsing regression · Line 55-59The docstring claims credentials are preserved, but the refactored `_split_uri` scans the whole remainder for the first '/' or '?' from index 0. A password containing a raw '/' or '?' (e.g. `clickhouse://user:pa/ss@host:8123/db`) truncates the authority before the '@', so `hostport` becomes `user:pa` and the migrated URI is corrupted. The previous `_swap_native_default_port` searched from after the last '@' and handled this; restore that scan.
-
Logger name inconsistency · Line 100-100Other migrations in this repo consistently use `logging.getLogger("alembic.env")` (e.g. `ce6bd21901ab`, `2bee73611e32`). Using `"alembic"` here routes the overflow warning to a different logger that alembic's logging config may not capture, so the skip warning at line 235 could be silently dropped. Align with the `alembic.env` convention.
-
Review Details
-
Files reviewed - 2 · Commit Range:
d8899a6..aa58f1e- superset/migrations/versions/2026-09-15_00-00_f7b3a9c14e02_migrate_clickhouse_to_clickhousedb.py
- tests/unit_tests/migrations/test_migrate_clickhouse_to_clickhousedb.py
-
Files skipped - 0
-
Tools
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers an incremental AI Review. -
/review full- Manually triggers a full AI Review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
| rewritten = [] | ||
| for pair in query.split("&"): | ||
| key, _, value = pair.partition("=") | ||
| if key == "protocol": | ||
| if value.lower() == "https": | ||
| rewritten.append("secure=true") | ||
| # protocol=http (the plaintext default) carries no meaning for | ||
| # clickhouse-connect and is dropped. | ||
| continue | ||
| rewritten.append(pair) | ||
| return "&".join(rewritten) |
There was a problem hiding this comment.
When a legacy URI carries both protocol=https and an existing secure param, _migrate_query appends secure=true without removing the old one, producing e.g. secure=true&secure=false. get_parameters_from_uri does dict(url.query) (last-wins), so encryption resolves to False — a silent TLS downgrade to plaintext, exactly what this migration exists to prevent. Drop any pre-existing secure when protocol=https. (CWE-319)
Code suggestion
Check the AI-generated fix before applying
| rewritten = [] | |
| for pair in query.split("&"): | |
| key, _, value = pair.partition("=") | |
| if key == "protocol": | |
| if value.lower() == "https": | |
| rewritten.append("secure=true") | |
| # protocol=http (the plaintext default) carries no meaning for | |
| # clickhouse-connect and is dropped. | |
| continue | |
| rewritten.append(pair) | |
| return "&".join(rewritten) | |
| rewritten = [] | |
| force_secure = any( | |
| key == "protocol" and value.lower() == "https" | |
| for key, _, value in (pair.partition("=") for pair in query.split("&")) | |
| ) | |
| for pair in query.split("&"): | |
| key, _, value = pair.partition("=") | |
| if key == "protocol": | |
| if force_secure: | |
| rewritten.append("secure=true") | |
| # protocol=http (the plaintext default) carries no meaning for | |
| # clickhouse-connect and is dropped. | |
| continue | |
| if force_secure and key == "secure": | |
| # protocol=https forces TLS; drop any pre-existing secure flag so | |
| # the query never carries conflicting/duplicate secure values. | |
| continue | |
| rewritten.append(pair) | |
| return "&".join(rewritten) |
Code Review Run #9aaf09
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️❗ @eschutho Your base branch
|
3 similar comments
🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️❗ @eschutho Your base branch
|
🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️❗ @eschutho Your base branch
|
🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️ 🙅♂️❗ @eschutho Your base branch
|
|
4 similar comments
|
|
|
|
0f0043b to
0eae123
Compare
| for row in rows: | ||
| last_id = row.id | ||
| try: | ||
| migrated = _rewrite(row.sqlalchemy_uri) |
There was a problem hiding this comment.
This only checks sqlalchemy_uri, but extra.engine_params.connect_args is forwarded to the new driver untouched. A legacy row with connect_args={"timeout": 30} now sends that to clickhouse-connect as a ClickHouse server setting, so every query fails with an unknown-setting error, and a CA path in verify is coerced to False by clickhouse-connect, which silently turns certificate verification off. Should rows with non-empty connect_args be skipped and logged like the other unmapped parameters?
| databases.c.id == row.id, | ||
| databases.c.sqlalchemy_uri == row.sqlalchemy_uri, | ||
| ) | ||
| .values(sqlalchemy_uri=migrated) |
There was a problem hiding this comment.
This rewrites sqlalchemy_uri but leaves configuration_method as it was (sqlalchemy_form for rows saved through the legacy spec), and the edit modal picks its form from that field (DatabaseModal/index.tsx:783) while the dynamic-form switch is hidden in edit mode (:2242). Migrated connections would still open on the SQLAlchemy URI editor instead of the new form. Should the migration also set configuration_method to dynamic_form for rewritten rows, and restore it on downgrade?
| URI parameters, a non-default native port, native TLS) stay on the legacy driver | ||
| and are logged by database id during the upgrade for manual migration. A | ||
| downgrade restores the original URI of every converted connection that has not | ||
| been edited since. `DISALLOWED_SQL_FUNCTIONS` gains a `clickhousedb` entry |
There was a problem hiding this comment.
TIME_GRAIN_ADDON_EXPRESSIONS is looked up by the spec's engine, so a custom grain configured under clickhouse (the 2-second example in config.py) stops resolving once the row is clickhousedb, and saved charts using it raise No grain spec for PT2S for database clickhousedb. The note only covers DISALLOWED_SQL_FUNCTIONS; should it also tell operators to copy their clickhouse time-grain entries to clickhousedb?
| # The lookup is keyed by engine spec ``engine``: ClickHouse connections use | ||
| # ``clickhouse`` (clickhouse-sqlalchemy) or ``clickhousedb`` (clickhouse-connect), | ||
| # and both drivers reach the same server functions. | ||
| DISALLOWED_SQL_FUNCTIONS["clickhousedb"] = set(DISALLOWED_SQL_FUNCTIONS["clickhouse"]) |
There was a problem hiding this comment.
This line is the only thing keeping rewritten connections under the ClickHouse function denylist, but nothing fails if it is dropped: the existing denylist tests either patch the config or use PostgreSQL. Could a test run an enforcement path with ClickHouseConnectEngineSpec and the default config and assert that SELECT version() is rejected while SELECT 1 passes?
…-connect Rewrites the sqlalchemy_uri of Database rows on the legacy `clickhouse` backend (clickhouse-sqlalchemy driver) to `clickhousedb+connect://` so they resolve to ClickHouseConnectEngineSpec and render the new dynamic connection form. - HTTP schemes (clickhouse://, clickhouse+http://) change scheme only; the HTTP port (8123) is preserved byte-for-byte along with credentials, database and query string. - Native schemes (clickhouse+native://, clickhouse+asynch://) also move the native default port 9000 to the HTTP port 8123 because clickhouse-connect is HTTP-only. Non-default native ports are left on the legacy driver. - Idempotent (rows already on clickhousedb are skipped). Downgrade is a documented no-op: migrated rows are indistinguishable from natively-created clickhousedb connections and remain functional after a rollback. - Merges the two open revision heads (88a01c781622, c7f53d184ea2). Story: https://app.shortcut.com/preset/story/120997 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Addresses PR review feedback: - Map legacy `protocol=https` to clickhouse-connect's `secure=true` (and drop the meaningless `protocol` param) so migrated TLS connections are not silently downgraded to plaintext HTTP (CWE-319). - Bound the credential-separator `@` search to the authority so an `@` in the path or query no longer corrupts host detection. - Skip (with a warning) rows whose rewritten URI would exceed the dbs.sqlalchemy_uri 1024-char column limit rather than truncating them. Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Reparent onto master's single head b8f3a2c91d64. #44288 merged the two former parents into e2f3a1b9c640, and several merges have since stacked on top of it, so the old tuple re-forked the graph. - HTTP rows: the legacy driver ignores `secure` and defaults to 8123 even for `protocol=https`, so drop stray `secure` (no duplicates / no silent plaintext->TLS flip) and pin 8123 when `secure=true` is introduced without a port (clickhouse-connect would otherwise pick 8443). - Native rows carrying TLS (`secure=true`) are skipped instead of being pointed at the plaintext HTTP port. - Parameters the drivers don't share (endpoint, timeout, ca_certs, header__*, a CA-path `verify`, ...) are no longer carried verbatim; the row stays on the legacy driver and its id is logged for the operator. - Exact rollback: upgrade records the original URI and a fingerprint of the migrated state in a migration-owned table; downgrade restores only unchanged converted rows, then drops the table (Databricks precedent). - Add `clickhousedb` to DISALLOWED_SQL_FUNCTIONS so the ClickHouse denylist follows rewritten rows. - Document the change in UPDATING.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, denylist)
- Skip (and log by id) rows whose extra.engine_params.connect_args is
non-empty, or whose extra cannot be inspected. clickhouse-connect sends
unknown keys such as `timeout` to the server as settings (every query
fails) and coerces a CA-bundle path in `verify` to False, silently
disabling certificate verification.
- Set configuration_method to `dynamic_form` on converted rows so the edit
modal opens the new form; record the original value and restore it on
downgrade alongside the URI (it is part of the rollback fingerprint).
- Add `time_grain_addon_aliases` to engine specs; ClickHouseConnectEngineSpec
declares ("clickhouse",), so TIME_GRAIN_ADDON_EXPRESSIONS configured under
`clickhouse` keep resolving for converted connections (both in
get_time_grain_expressions and the partition-mirroring width check), with
`clickhousedb` entries taking precedence.
- Test that the default config's ClickHouse function denylist is enforced
on a clickhousedb connection: `SELECT version()` is rejected and
`SELECT 1` runs, without patching config.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
0eae123 to
eba10e7
Compare
A stale local ruff reformatted two existing asserts; restore master's formatting so the file only carries the new test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@sadpandajoe thanks for the review. All four points are addressed in 1. 2. 3. 4. Denylist enforcement untested on Verification
cc @rusackas: the branch is rebased onto current master, and the migration parents on master's actual single head, |
|
@sadpandajoe quick heads up — all four points from your review are addressed (details and tests in this reply, commits |
|
|
1 similar comment
|
rusackas
left a comment
There was a problem hiding this comment.
Thanks @eschutho, really thorough work here, and nice to see the UPDATING.md note already covering the driver swap.
One thing before approving... #43499 landed on master today with dfa683969f48, which also chains off b8f3a2c91d64, so after the merge from master this leaves two heads. That's what enforce-single-migration-head and the test jobs are tripping on. Can you repoint down_revision (and the Revises: line in the docstring) at dfa683969f48?
Heads up that #44278 hangs off b8f3a2c91d64 too, so whichever of the two lands second will need the same repoint.
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "f7b3a9c14e02" | ||
| down_revision = "b8f3a2c91d64" |
There was a problem hiding this comment.
This should do it, plus the matching Revises: line up top:
| down_revision = "b8f3a2c91d64" | |
| down_revision = "dfa683969f48" |
| `superset db upgrade`, so they use the dynamic connection form. Install | ||
| `clickhouse-connect>=0.13.0` before upgrading. HTTP connections keep their port; |
There was a problem hiding this comment.
Small one, 0.13.0 is well below what the clickhouse extra in pyproject.toml pins on master (>=1.11.0, <2.0), so pointing folks at the extra seems safer:
| `superset db upgrade`, so they use the dynamic connection form. Install | |
| `clickhouse-connect>=0.13.0` before upgrading. HTTP connections keep their port; | |
| `superset db upgrade`, so they use the dynamic connection form. Install the | |
| `clickhouse` extra (`clickhouse-connect>=1.11.0, <2.0`) before upgrading. HTTP connections keep their port; |
…e-legacy-migration
…e head Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
mikebridge
left a comment
There was a problem hiding this comment.
Re-review: the earlier migration-head conflict and the concrete denylist, TLS/port, rollback, parameter-handling, and edit-form issues are addressed in this head. The required checks are green. Thanks for working through this substantial migration.
@rusackas, the migration now chains off dfa683969f48, so the head conflict you mentioned is fixed. The PR summary still says b8f3a2c91d64 and could be updated to match.
superset/migrations/versions/2026-11-23_00-00_f7b3a9c14e02_migrate_clickhouse_to_clickhousedb.py:385-394:downgrade()checks a fingerprint containing the URI, form, andchanged_on, but its update then matches onlyidand URI. An edit to the form orextrabetween the read and update can be followed by restoration against that newer state. Could the update also match the checkedconfiguration_methodandchanged_on, and warn when no row is updated? The upgrade already uses a conditional update for its URI.UPDATING.md:247: Evan's existing suggestion is still applicable: the install note saysclickhouse-connect>=0.13.0, while theclickhouseextra inpyproject.tomlrequires>=1.11.0, <2.0.
I did not rerun a live ClickHouse connection; this review covers the exact current PR diff and its green CI evidence.
rusackas
left a comment
There was a problem hiding this comment.
Thanks @eschutho, the repoint is in. But #46479 landed on master right after with a7d29bc4e681, which also hangs off dfa683969f48... so we're back to two heads. Mind moving down_revision (and the Revises: line) to a7d29bc4e681?
Also, my UPDATING.md suggestion on the clickhouse-connect version is still open.
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "f7b3a9c14e02" | ||
| down_revision = "dfa683969f48" |
There was a problem hiding this comment.
Same deal as last time, plus the Revises: line up top:
| down_revision = "dfa683969f48" | |
| down_revision = "a7d29bc4e681" |
…e head (a7d29bc4e681) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mikebridge
left a comment
There was a problem hiding this comment.
Re-review at e906ddf1: comment, no blocker. The only PR change since my last review is the re-point to a7d29bc4e681. The nine-file diff is otherwise identical after the master merge, but master has moved again.
Earlier points
down_revisionhead conflict: fixed fora7d29bc4e681, but see the first item below.downgrade()conditional update (superset/migrations/versions/2026-11-23_00-00_f7b3a9c14e02_migrate_clickhouse_to_clickhousedb.py:385-394): still open. TheUPDATEmatches onlyidand URI, not the checkedconfiguration_method/changed_on, and the rowcount isn't checked.UPDATING.md:280: still saysclickhouse-connect>=0.13.0, while theclickhouseextra pins>=1.11.0, <2.0(Evan's suggestion still applies).
New
…f7b3a9c14e02….py:98,119: master now has7b9d2f8a6c31(add_teams_installations, #45508), which also revisesa7d29bc4e681, so merging as-is creates two heads. It needs one more re-point to7b9d2f8a6c31right before merge.…f7b3a9c14e02….py:242: a plaintext legacy row on port 8443 or 443 would switch to TLS. The rewrite dropsprotocol=http/secureand emits nothing for plaintext. clickhouse-connect'screate_clientsetsuse_tlswhen nointerfaceis given and the port is443/8443, and the SQLAlchemy dialect passes nointerface. Soclickhouse://host:8443/db(plaintext under the legacy driver) becomes a TLS connection. That's an unusual setup, but it breaks the "meaning carried across exactly" rule in the docstring. Emittingsecure=falsefor non-TLS rows on those ports, or skipping them, would close it. A test case next to the:8443one attests/unit_tests/migrations/test_migrate_clickhouse_to_clickhousedb.py:128would cover it.…f7b3a9c14e02….py:286(minor): whenconnect_argsisn't a dict, the exception embedsconnect_args!r, and:329-333logs it at WARNING. A malformed string or list carrying a credential would end up in deploy logs. A fixed reason for the non-dict case avoids that.
CI: the red validate-all-ghas is the zizmor SARIF upload step. This PR touches no workflows, so it doesn't look related.
I didn't run a live ClickHouse connection. The TLS point comes from reading the clickhouse-connect driver source, not from a connection test.
|
SUMMARY
Part of epic sc-120993 (migrate DB connections to the new dynamic connection form). Story: https://app.shortcut.com/preset/story/120997
Superset ships two ClickHouse engine specs:
ClickHouseEngineSpec: backend keyclickhouse, theclickhouse-sqlalchemydriver. Legacy, with noparameters_schema, so its connections still render the free-form SQLAlchemy URI editor.ClickHouseConnectEngineSpec: backend keyclickhousedb, default driverconnect(clickhouse-connect). Definesparameters_schemaand renders the new dynamic connection form.The engine spec is picked from the URI's backend name, so this data migration rewrites saved legacy
clickhouse[+driver]://URIs toclickhousedb+connect://. A row is rewritten only when its meaning carries over exactly. Every other row stays on the legacy driver, which keeps working, and its id is logged duringsuperset db upgradeso an operator can migrate it by hand.The migration chains off master's single head
b8f3a2c91d64.Scheme / port / TLS mapping
The legacy HTTP dialect builds
f"{protocol}://{host}:{url.port or 8123}/{endpoint}". TLS comes only from?protocol=https, the port defaults to 8123 whatever the protocol, andsecureis never read.clickhouse-connectreadssecureand defaults TLS connections to 8443.clickhouse://,clickhouse+http://clickhousedb+connect://protocol=httpsbecomessecure=true, and 8123 is pinned if no port was set.protocol=httpand straysecureare dropped.verify=true|falseis kept.clickhouse+native://,clickhouse+asynch://clickhousedb+connect://secureis dropped.Left on the legacy driver (logged by id): any other URI parameter, since the drivers don't share a vocabulary (the legacy
endpointis the HTTP path; clickhouse-connect forwards unknown keys as server settings and rejects ones it doesn't recognize); a CA-pathverify; a non-default native port; native TLS (secure=true); a rewritten URI that would overflow the 1024-character column; and any non-emptyextra.engine_params.connect_args(or anextrathat cannot be parsed). Both drivers receiveconnect_argsas keyword arguments, but clickhouse-connect sends unknown keys such astimeoutto the server as settings and coerces a CA-bundle path inverifytoFalse, which would silently disable certificate verification.Converted rows also get
configuration_method = 'dynamic_form', so the edit modal opens the new form instead of the SQLAlchemy URI editor.Credentials live in the separately encrypted
passwordcolumn, and the URI only carries the masked placeholder. The migration never reads or writespasswordorencrypted_extra.DISALLOWED_SQL_FUNCTIONSgains aclickhousedbentry equal toclickhouse. That lookup is keyed byengine, so without the entry, converted connections (and connections created directly onclickhousedb) bypassed the ClickHouse function denylist. A unit test runsDatabase.executeon aclickhousedbconnection against the unpatched default config, asserting thatSELECT version()is rejected andSELECT 1runs, so dropping that entry fails CI.Engine specs gain
time_grain_addon_aliases, andClickHouseConnectEngineSpecdeclares("clickhouse",).TIME_GRAIN_ADDON_EXPRESSIONSentries configured underclickhousetherefore keep resolving for converted connections, withclickhousedbentries taking precedence. The alias applies in bothget_time_grain_expressionsand the partition-mirroring bucket-width check.Rollback
upgraderecords each converted row's original URI, its originalconfiguration_method, and a fingerprint of its migrated state in a migration-owned table,clickhouse_uri_migration.downgraderestores both only for rows whose fingerprint still matches, then drops the table. Connections edited after the upgrade, and connections created directly onclickhousedb, are left untouched. This follows the in-tree Databricks URI migration (b8f3a2c91d64).upgradeis idempotent.TESTING INSTRUCTIONS
pytest tests/unit_tests/migrations/test_migrate_clickhouse_to_clickhousedb.pyruns 49 cases against real Alembic operations: HTTP/native/TLS mapping, port pinning, skipped rows and their warnings, idempotency, an exact round trip, a downgrade that leaves edited or native rows alone,configuration_methodswitching and restoring, and rows skipped forconnect_args.flask db upgrade→downgrade b8f3a2c91d64→upgradecycle on SQLite, seeded with legacy rows, restored the original URIs andconfiguration_methodbyte-for-byte, and left aconnect_argsrow on the legacy driver with a warning.superset db headsprints a single head.clickhouse://user:pass@host:8123/dbconnection, runsuperset db upgrade, then edit the connection. It now renders the dynamic ClickHouse form.ADDITIONAL INFORMATION
Runtime: keyset-batched updates over
dbsrows whose URI starts withclickhouse(about 30 rows across the fleet). Runtime is negligible and there is no downtime. Documented inUPDATING.md.🤖 Generated with Claude Code