What
The connection string gets parsed by _ConnectionStringParser more than once on every connect when Entra ID auth is in play.
For one Entra ID connect today:
Connection.__init__ calls _construct_connection_string, which parses once.
process_connection_string (in auth.py) splits the string again to pick out auth params.
- For MSI with UID,
_extract_msi_client_id parses it a third time via _ConnectionStringParser.
Same string, three parses. Small per-connect cost, but it's wasted work and it's also why auth.py keeps reimplementing parsing instead of trusting the canonical parser.
Why fix it
- Removes redundant work on the connect path.
- Lets
auth.py stop hand-rolling its own parsing (the naive split(";") in process_connection_string and extract_auth_type only exists because the parsed map isn't available at that point).
- Makes the bracing-value bug ([separate issue](TBD link)) trivial to fix as a side effect.
Suggested approach
Connection.__init__ already produces a parsed map via _construct_connection_string. Hold on to it (or re-run the parser once and pass the dict around).
- Change
process_connection_string (and extract_auth_type, and _extract_msi_client_id) to take the parsed dict instead of the raw string. Read keys from the dict directly.
- Build the sanitized output via
_ConnectionStringBuilder from the same dict (minus the sensitive keys).
Same call shape from the outside, one parse instead of three, and auth.py stops carrying its own mini-parser.
Workaround mentioned in the review
A connection-string → uid hashmap was suggested as an ad-hoc fix. Skipping it because it has its own concurrency and lifecycle problems and doesn't address the deeper "auth.py shouldn't reparse" issue.
Background
Surfaced during PR #573 review.
What
The connection string gets parsed by
_ConnectionStringParsermore than once on every connect when Entra ID auth is in play.For one Entra ID connect today:
Connection.__init__calls_construct_connection_string, which parses once.process_connection_string(inauth.py) splits the string again to pick out auth params._extract_msi_client_idparses it a third time via_ConnectionStringParser.Same string, three parses. Small per-connect cost, but it's wasted work and it's also why
auth.pykeeps reimplementing parsing instead of trusting the canonical parser.Why fix it
auth.pystop hand-rolling its own parsing (the naivesplit(";")inprocess_connection_stringandextract_auth_typeonly exists because the parsed map isn't available at that point).Suggested approach
Connection.__init__already produces a parsed map via_construct_connection_string. Hold on to it (or re-run the parser once and pass the dict around).process_connection_string(andextract_auth_type, and_extract_msi_client_id) to take the parsed dict instead of the raw string. Read keys from the dict directly._ConnectionStringBuilderfrom the same dict (minus the sensitive keys).Same call shape from the outside, one parse instead of three, and
auth.pystops carrying its own mini-parser.Workaround mentioned in the review
A connection-string → uid hashmap was suggested as an ad-hoc fix. Skipping it because it has its own concurrency and lifecycle problems and doesn't address the deeper "auth.py shouldn't reparse" issue.
Background
Surfaced during PR #573 review.