Skip to content

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

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

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>
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