Skip to content

Preserve IPv6 brackets in remote connection URLs - #16

Draft
Kayvan-Zahiri wants to merge 1 commit into
tursodatabase:mainfrom
Kayvan-Zahiri:codex/preserve-ipv6-url-brackets
Draft

Kayvan-Zahiri wants to merge 1 commit into
tursodatabase:mainfrom
Kayvan-Zahiri:codex/preserve-ipv6-url-brackets

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Problem

SQLAlchemy exposes an IPv6 URL's host without brackets. The libSQL dialect copies that value directly into the HTTP authority, producing URLs such as http://::1:8080/database. That is not a valid IPv6 authority and cannot be parsed into the intended host and port.

Change

Restore brackets around IPv6 host literals when constructing the remote URL. IPv4 addresses and DNS hostnames retain their existing formatting. The same formatted host is used in all existing user-info branches.

Validation

  • Eight tests use the public SQLAlchemy create_engine API and dialect connection arguments, covering loopback/documentation IPv6 addresses, IPv4, DNS, and HTTP/HTTPS. They also verify the resulting hostname and port with the standard URL parser.
  • Four IPv6 cases fail before this change; four IPv4/DNS controls pass.
  • pytest tests/test_connection_urls.py tests/test_basic.py -q: 28 passed after the fix, including actual in-memory/local-file libSQL operations.
  • Full pytest tests/ -q: 40 passed, 8 failed, 4 errors. The failures are existing async-adapter behavior (Cursor._async_soft_close missing and transaction teardown errors). Running the async tests with unchanged libsql.py reproduces the same eight failures and four errors (12 pass). No failures are suppressed.
  • compileall and git diff --check pass.

Python 3.12; SQLAlchemy 2.1.6; libsql-experimental 0.0.55. No hosted database, auth token, IPv6 server connection, or embedded replication was used. Without remote configuration, the existing remote/embedded fixture variants fall back to in-memory databases; those are not claimed as remote integration coverage.

This is independent of the dependency migration in #15 and does not change the DBAPI dependency.

AI assistance: OpenAI Codex assisted with reproduction, patch, tests, and this description.

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.

1 participant