Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/snowflake/snowpark/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3628,7 +3628,8 @@ def write_pandas(
**kwargs,
)
except ProgrammingError as pe:
if pe.msg.endswith("does not exist"):
msg = getattr(pe, "raw_msg", pe.msg)
if msg.endswith("does not exist"):
Comment on lines +3631 to +3632

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential AttributeError if raw_msg attribute exists but is None. The getattr function only returns the default value when the attribute doesn't exist, not when it exists with a None value. If pe.raw_msg is None, line 3632 will call None.endswith() and crash.

Fix:

msg = getattr(pe, "raw_msg", None) or pe.msg
if msg.endswith("does not exist"):

Or add a null check:

msg = getattr(pe, "raw_msg", pe.msg)
if msg and msg.endswith("does not exist"):
Suggested change
msg = getattr(pe, "raw_msg", pe.msg)
if msg.endswith("does not exist"):
msg = getattr(pe, "raw_msg", None) or pe.msg
if msg.endswith("does not exist"):

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

raise SnowparkClientExceptionMessages.DF_PANDAS_TABLE_DOES_NOT_EXIST_EXCEPTION(
location
) from pe
Expand Down
Loading