Skip to content

fix: escape embedded closing braces in pyodbc connection string values#734

Merged
axellpadilla merged 1 commit into
dbt-msft:masterfrom
joshmarkovic:fix/pyodbc-brace-escaping
Jul 3, 2026
Merged

fix: escape embedded closing braces in pyodbc connection string values#734
axellpadilla merged 1 commit into
dbt-msft:masterfrom
joshmarkovic:fix/pyodbc-brace-escaping

Conversation

@joshmarkovic

Copy link
Copy Markdown
Contributor

Problem

Connection string values for the pyodbc backend are wrapped in braces, for example PWD={my-password}. If the value itself contains a closing brace (say a password like pa}ss), the driver treats that } as the end of the value and misparses the rest of the connection string, so the connection fails.

Fix

Inside a brace-quoted ODBC value, a literal } must be written as }}. format_connection_string_value() now doubles closing braces before wrapping the value. The mssql-python path is unchanged; its helper (escape_connection_string_value) already escaped braces this way.

Testing

  • New unit tests cover values with braces, None, and delegation to the mssql-python helper.
  • Full unit suite passes (270 tests). ruff and black are clean.

The pyodbc branch of format_connection_string_value wrapped values in
braces without doubling embedded closing braces, so a password like
pa}ss produced PWD={pa}ss} and the driver misparsed the rest of the
connection string. The mssql-python branch already escaped correctly.
Double the closing brace per the ODBC quoting rules and cover both
backends with unit tests.
@joshmarkovic joshmarkovic marked this pull request as ready for review July 3, 2026 00:26
@axellpadilla axellpadilla enabled auto-merge July 3, 2026 15:54
@axellpadilla axellpadilla merged commit 45d5c4b into dbt-msft:master Jul 3, 2026
5 of 17 checks passed
@axellpadilla axellpadilla added this to the v1.10.1 milestone Jul 3, 2026
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