Repository navigation
Fix empty SQLAlchemy User-Agent tags - #84
Merged
Merged
Conversation
Keep the empty-entry result from being overwritten by the custom-tag branch. Add offline coverage for missing and null tags, legacy arguments, idempotency and engine connection events. Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
cathleeny
requested review from
deeksha-db,
gopalldb,
jackyhu-db,
jayantsing-db,
jprakash-db,
samikshya-db,
shivam2680 and
vikrantpuppala
as code owners
November 18, 2026 23:30
cathleeny
requested review from
vuanhphung
and removed request for
deeksha-db,
gopalldb,
jackyhu-db,
jayantsing-db,
jprakash-db,
samikshya-db and
shivam2680
November 19, 2026 17:11
vuanhphung
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What did you change, and why?
Why: When no custom
user_agent_entryis given (missing, empty, orNone), the SQLAlchemy connect hook sendssqlalchemy +orsqlalchemy + Noneas the User-Agent tag instead ofsqlalchemy. A second, independentif/elseinadd_sqla_tag_if_not_presentoverwrites the empty-entry result.Change: Make the branches mutually exclusive (
if / elif / else), so an empty entry becomessqlalchemy. Non-empty entries, the existing-tag check, legacy_user_agent_entryprecedence, and idempotency across repeated connects are unchanged. This change only fixes the malformed empty-entry tag and does not change how already-tagged values are handled.How do you know it works?
Testing:
tests/test_local/test_user_agent.py, with 17 offline cases:NoneentriesEngine.connect()event path, stopped at the DBAPI boundary before any network calldatabricks-sql-connector4.9.0 and SQLAlchemy 2.1.8:main.tests/test_local, excludinge2e, pass with the fix.black --check srcpasses.This pull request and its description were written by Isaac.