Skip to content

Deprecate DSN environment variable in favor of MYSQL_DSN#1745

Merged
rolandwalker merged 1 commit intomainfrom
RW/deprecate-dsn-environment-variable
Mar 27, 2026
Merged

Deprecate DSN environment variable in favor of MYSQL_DSN#1745
rolandwalker merged 1 commit intomainfrom
RW/deprecate-dsn-environment-variable

Conversation

@rolandwalker
Copy link
Copy Markdown
Contributor

Description

Unlike similar environment variables, this didn't have the MYSQL_ prefix. We can deprecate pretty freely here since this was not documented.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Mar 26, 2026
@github-actions
Copy link
Copy Markdown

  1. Medium – Deprecation warning is emitted even when legacy DSN is not used
    In mycli/main.py:2347, the warning is printed whenever DSN exists in the environment, even if cli_args.dsn was already set via --dsn or MYSQL_DSN.
    Action: only emit the warning when fallback actually applies (move click.secho(...) inside if not cli_args.dsn:), and ideally only when DSN is non-empty.

  2. Low – Missing tests for the new env-var migration path
    This PR changes option env binding and adds manual fallback, but there are no tests covering it in test/pytests/test_main.py.
    Action: add tests for:

    • MYSQL_DSN populates cli_args.dsn (happy path).
    • DSN fallback works when MYSQL_DSN is unset, with deprecation warning.
    • precedence when both are set (MYSQL_DSN should win), and warning behavior is explicit/intentional.

No direct security issue found in the diff.

I couldn’t run tests locally because pytest is not installed in this environment.

Unlike similar environment variables, this didn't have the MYSQL_
prefix.  We can deprecate pretty freely here since this was not
documented.
@rolandwalker rolandwalker force-pushed the RW/deprecate-dsn-environment-variable branch from 7740de0 to ecd2613 Compare March 26, 2026 09:46
@rolandwalker rolandwalker merged commit b3ec076 into main Mar 27, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/deprecate-dsn-environment-variable branch March 27, 2026 08:48
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