| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…buteError' on __del__ (#746) Signed-off-by: peco-engineer-bot[bot] <3815206+peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — the hasattr(self, "session") guard in Connection.__del__ correctly fixes the AttributeError, since the username/password ValueError is raised inside Session.__init__ (session.py:121 → auth.py:109) before self.session is assigned. One low note: the regression test is E2E-only despite covering purely client-side behavior that could be unit-tested.
Sorry, something went wrong.
Addresses: - #3635886434 at tests/e2e/test_driver.py:1159 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Summary
Automated fix for #746 — Session is not set in object if connection fails, which raises 'AttributeError' on del.
Added a hasattr(self, "session") guard at the top of Connection.__del__ in src/databricks/sql/client.py so that when the Session constructor raises before self.session is assigned, garbage-collecting the half-constructed Connection no longer triggers AttributeError via the open property. Verified with the E2E test that forces a constructor-stage failure (username/password → ValueError) and asserts nothing escapes del.
Root cause & plan
Root cause: In Connection.init (src/databricks/sql/client.py:321), self.session = Session(...) runs inside a try/except. If the Session CONSTRUCTOR raises before the assignment completes (e.g. client-side auth validation such as passing username/password -> ValueError, or use_kernel+use_sea -> ValueError, or an OAuth provider whose constructor makes a failing network call), then self.session is never bound and the exception propagates out of init. When the half-constructed Connection is garbage-collected, del (client.py:464) executes if self.open:, and the open property (client.py:509) evaluates self.session.is_open. Since session is absent, this raises AttributeError: 'Connection' object has no attribute 'session', which Python reports as an 'Exception ignored in del' warning on stderr. Note: a bad host / bad token does NOT trigger this, because those fail in Session.open() (after self.session is assigned); only a constructor-stage failure leaves session unset.
Files: src/databricks/sql/client.py, tests/e2e/test_driver.py
Planned coverage:
Files changed
Test plan
🤖 Generated by engineer-bot (bug-fix flow) — review before merge.