Skip to content

Encode slashes in DSN usernames - #2446

Merged
rolandwalker merged 1 commit into
dbcli:mainfrom
sxwangsxwang1:fix-dsn-username-slash
Nov 18, 2026
Merged

rolandwalker merged 1 commit into
dbcli:mainfrom
sxwangsxwang1:fix-dsn-username-slash

Conversation

@sxwangsxwang1

Copy link
Copy Markdown
Contributor

Description

A username such as team/alice produces mysql://team/alice@db.example.com:3307/prod when showing or saving a DSN. Reusing that alias treats team as the hostname and loses the original username, port, and database.

Percent-encode / in the username so the DSN becomes mysql://team%2Falice@db.example.com:3307/prod. The regression saves and reloads an alias, then checks the connection arguments through the CLI dispatcher. It covers TCP and Unix sockets, both alias environment-expansion modes, and usernames containing /, literal %2F, @, and Unicode.

Validation on Python 3.14.3:

  • Before the fix: the new regression has 8 failures and 8 passing controls.
  • After the fix: the CLI runner, DSN aliases, special utilities, client connection, and DSN-list test files have 287 passed and 1 skipped.
  • Repository-wide ruff check, ruff format --check, and mypy --install-types --non-interactive . passed.

No live MySQL server or full tox/behave integration run was used. The tests exercise real DSN generation and configuration persistence, with a dummy connection target.

AI assistance: Codex assisted with the fix, tests, and this description. The checks listed above were run locally by Codex.

Checklist

  • I added this contribution to the changelog.md file.

  • I added my name to the mycli/AUTHORS.txt file (or it's already there).

  • To lint, check formatting, and check types, I ran:

    env -u PYTHONPATH uv run --no-sync -- ruff check
    env -u PYTHONPATH uv run --no-sync -- ruff format --check
    env -u PYTHONPATH uv run --no-sync -- mypy --install-types --non-interactive .

@rolandwalker

Copy link
Copy Markdown
Contributor

Hi! Great! Thanks!

@rolandwalker
rolandwalker merged commit a87495a into dbcli:main Nov 18, 2026
13 checks passed
@rolandwalker

Copy link
Copy Markdown
Contributor

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.

2 participants