Skip to content

Fix connect ignoring server_public_key - #1079

Draft
Ishubhammohole wants to merge 1 commit into
aio-libs:mainfrom
Ishubhammohole:fix-670-forward-server-public-key
Draft

Ishubhammohole wants to merge 1 commit into
aio-libs:mainfrom
Ishubhammohole:fix-670-forward-server-public-key

Conversation

@Ishubhammohole

Copy link
Copy Markdown

Summary

  • Forward the existing server_public_key argument through connect() to Connection, so it is available before authentication starts.
  • Add regression coverage for both await connect() and async with connect(), with supplied and omitted keys on asyncio and uvloop. Only network connection setup is replaced in these tests.

Testing

  • .venv/bin/pytest -q tests/test_connection.py -k test_connect_server_public_key --tb=short: 8 passed; before the fix, 4 failed and 4 passed.
  • .venv/bin/flake8 aiomysql tests examples: passed.
  • git diff --check: passed.
  • Full database integration suite not run: docker info cannot connect to the Docker daemon, and no isolated test database was available. No claim of live-server authentication testing.

Prepared with Codex assistance.

Fixes #670

@Ishubhammohole

Ishubhammohole commented Sep 19, 2026 •

Copy link
Copy Markdown
Author

CI note: the database matrix completed its test steps successfully. All 40 matrix jobs are red only at Upload coverage; for example, Python 3.13 / MySQL 8.0 reports 987 passed, 22 skipped, 4 xfailed, then Codecov fails GPG verification with "No public key". The final aggregate check consequently fails too.

Separately, pre-commit.ci crashes inside the existing pyupgrade 3.21.0 hook on Python 3.14: tokenize.cookie_re.match(token.src) raises TypeError: cannot use a bytes pattern on a string-like object. The hook configuration is unchanged. Flake8, distribution build, documentation, and CodeQL passed. Tooling/dependency changes are intentionally outside this focused fix.

@greptile-apps

greptile-apps Bot commented Sep 19, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

Safe to merge: the connection factory preserves the public key through the pre-authentication connection setup path.

What we checked:

  • Ran a focused connection regression across awaited and async context-managed calls with supplied and omitted public keys, and all eight cases passed. T-Rex
  • Executed a focused verifier that observes Connection.server_public_key at the handshake boundary and after acquisition. T-Rex
  • Validated that the supplied key is preserved in both public connection paths, while omitted-key calls consistently return None. T-Rex
  • Verified the prior and after logs and the verification script, confirming the handshake behavior and key-forwarding observations. T-Rex

Reviews (1) · Last reviewed commit: "fix: forward server_public_key to connec..."

@Ishubhammohole
Ishubhammohole marked this pull request as draft September 19, 2026 16:55

This branch has not been deployed

No deployments
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.

aiomysql.connect ignores server_public_key argument

1 participant