Skip to content

[Python][FS][Azure] C++ Exceptions leaking from PyArrow #44269

@Tjev

Description

@Tjev

Describe the bug, including details regarding any error messages, version, and platform.

There seem to be few C++ Exceptions leaking from the pyarrow implementation of the pyarrow.fs.AzureFileSystem.

One example is the Azure::core::Http::TransportException: Timeout waiting for socket to read coming from the Azure C++ SDK.

Another example is that if user provides the AzureFileSystem class constructor with account_key which is not a valid base64 encoded string, this exception is raised and kills the process:
libc++abi: terminating due to uncaught exception of type std::runtime_error: Unexpected character in Base64 encoded string

Would it be please possible to catch the C++ Exceptions such as the TransportException and raise them as Python exception of some kind?
It would enable the users to decide how to handle such issues instead of failing/crashing the user application.

To reproduce

example 1:

>>> import pyarrow.fs
>>> fs = pyarrow.fs.AzureFileSystem(account_name="doesntexist", account_key="bl==")
>>> fs.create_dir("bla/bla")
libc++abi: terminating due to uncaught exception of type Azure::Core::Http::TransportException: Fail to get a new connection for: https://doesnt_exist.dfs.core.windows.net. Couldn't resolve host name

example 2:

>>> import pyarrow.fs
>>> fs = pyarrow.fs.AzureFileSystem(account_name="doesntexist", account_key="bla")
>>> fs.create_dir("bla/bla")
libc++abi: terminating due to uncaught exception of type std::runtime_error: Unexpected character in Base64 encoded string

Versions

Python version: 3.12.2
PyArrow version: 17.0.0

Component(s)

Python

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions