Skip to content

Commit 1253f8d

Browse files
authored
fix: Fix passing down application_credentials to GCSStore (#541)
1 parent 8f33d53 commit 1253f8d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pyo3-object_store/src/gcp/store.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ pub struct PyGoogleConfigKey(GoogleConfigKey);
214214
impl<'py> FromPyObject<'py> for PyGoogleConfigKey {
215215
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
216216
let s = ob.extract::<PyBackedStr>()?.to_lowercase();
217+
// https://github.com/apache/arrow-rs-object-store/pull/467
218+
if s == "application_credentials" {
219+
return Ok(Self(GoogleConfigKey::ApplicationCredentials));
220+
}
221+
217222
let key = s.parse().map_err(PyObjectStoreError::ObjectStoreError)?;
218223
Ok(Self(key))
219224
}

tests/store/test_gcs.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from obstore.exceptions import BaseError
3+
from obstore.exceptions import BaseError, GenericError
44
from obstore.store import GCSStore
55

66

@@ -19,3 +19,11 @@ def test_eq():
1919
assert store == store # noqa: PLR0124
2020
assert store == store2
2121
assert store != store3
22+
23+
24+
def test_application_credentials():
25+
# The application_credentials parameter should be correctly passed down
26+
# Finalizing the GCSBuilder should try to load and parse those credentials, which
27+
# should error here.
28+
with pytest.raises(GenericError, match="source: OpenCredentials"):
29+
GCSStore("bucket", application_credentials="path/to/creds.json")

0 commit comments

Comments
 (0)