Skip to content

fix(utils): import ProgrammingError instead of bare exc. reference#802

Closed
vikrantpuppala wants to merge 1 commit into
mainfrom
fix/utils-missing-exc-import
Closed

fix(utils): import ProgrammingError instead of bare exc. reference#802
vikrantpuppala wants to merge 1 commit into
mainfrom
fix/utils-missing-exc-import

Conversation

@vikrantpuppala
Copy link
Copy Markdown
Contributor

Summary

ParamEscaper.escape_args and ParamEscaper.escape_item both raise exc.ProgrammingError(...) (lines 551 and 609 of utils.py), but exc is never imported. On any unsupported parameter shape the user sees NameError: name 'exc' is not defined instead of a clean PEP-249 ProgrammingError.

Surfaced via the python-comparator audit harness running the INLINE_PARAMS connection config: both backends raised NameError: name 'exc' is not defined, which the comparator's class+message match treated as parity — a false-positive that hid both the real driver bug and the underlying caller-side type mismatch.

Fix

Import ProgrammingError directly from databricks.sql.exc (matching the pattern used in session.py, client.py, result_set.py, etc.) and replace the two exc.ProgrammingError(...) sites with bare ProgrammingError(...).

Test plan

  • Manual repro: pe = ParamEscaper(); pe.escape_args(object()) now raises ProgrammingError, not NameError. Same for pe.escape_item(object()).
  • Existing test suite — no behaviour change beyond the exception class on a previously-unreachable error path.

This pull request and its description were written by Isaac.

`ParamEscaper.escape_args` and `ParamEscaper.escape_item` both raise
`exc.ProgrammingError(...)` but `exc` was never imported into utils.py.
On any unsupported parameter shape the user sees `NameError: name 'exc'
is not defined` instead of a clean PEP-249 `ProgrammingError`, masking
the actual problem.

Surfaced via the python-comparator audit harness running the
`INLINE_PARAMS` connection_config: both backends raised
`NameError: name 'exc' is not defined`, which the comparator's
class+message match treated as parity — a false-positive that hid both
the real driver bug and the underlying caller-side type mismatch.

Fix: import `ProgrammingError` directly from `databricks.sql.exc`
(matching the pattern used in `session.py`, `client.py`, `result_set.py`,
etc.) and replace the two `exc.ProgrammingError(...)` sites with bare
`ProgrammingError(...)`.

Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
@vikrantpuppala
Copy link
Copy Markdown
Contributor Author

Folded into #803 as part of a bundle of five comparator-parity fixes that share the same audit baseline. The exc.ProgrammingError import fix is item #5 in the updated #803 description. Closing this in favour of the bundled review.

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.

1 participant