Sitelet https://github.com/OtterMind/Chat2DB/issues/2685
Skip to content

bug(clickhouse): switching schema corrupts IPv6 JDBC URLs #2685

Description

@HandSonic

Chat2DB Edition

Chat2DB Community

Chat2DB Version

main at 2442df9

Deployment

Web and Desktop

Operating System

Any

Database and Version

ClickHouse with JDBC access over IPv6

Problem Summary

Switching a ClickHouse connection to another schema corrupts bracketed IPv6 JDBC URLs. ClickHouseDBManager splits the URL using the bare host and port as a regular expression, which cannot match the bracketed IPv6 authority and does not safely preserve URL query or fragment suffixes.

Steps to Reproduce

  1. Configure a ClickHouse connection with URL jdbc:clickhouse://[2001:db8::1]:8123/default?ssl=true.
  2. Store the connection host as 2001:db8::1 and port as 8123.
  3. Switch the connection schema to analytics.

Expected Behavior

The URL becomes jdbc:clickhouse://[2001:db8::1]:8123/analytics?ssl=true and remains stable on reconnect. Query parameters and ClickHouse fragment tags are preserved.

Actual Behavior

The host and port split does not match the bracketed authority. The implementation appends the bare address and schema to the existing URL, producing a malformed value such as jdbc:clickhouse://[2001:db8::1]:8123/default?ssl=true2001:db8::1:8123/analytics. The bad URL is then written back to ConnectInfo.

Logs

The ClickHouse driver rejects the malformed JDBC URL or connects with the wrong database.

Screenshots or Additional Context

ClickHouse supports schema switching and fragment tags. URL rewriting should replace only the database path while preserving the authority, query, and fragment boundaries.

Impact

IPv6 ClickHouse connections cannot reliably switch databases and reconnect attempts can reuse the corrupted URL.

Workaround

Manually restore the JDBC URL and avoid switching schemas from Chat2DB.

Submission Checklist

  • Reproduced on the selected Chat2DB edition.
  • Searched existing issues and pull requests for duplicates.
  • Removed credentials and private data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    In Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions