Skip to content

Commit d1ac0cb

Browse files
authored
fix: Raise error when passing credential provider with http url (#465)
1 parent bd9911d commit d1ac0cb

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

obstore/python/obstore/store.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def from_url( # noqa: C901
797797
**kwargs,
798798
)
799799
if scheme == "http":
800-
if config or kwargs:
800+
if config or kwargs or credential_provider:
801801
msg = "HTTPStore does not accept any configuration"
802802
raise BaseError(msg)
803803

@@ -813,6 +813,9 @@ def from_url( # noqa: C901
813813
automatic_cleanup = kwargs.pop("automatic_cleanup")
814814
if "mkdir" in kwargs:
815815
mkdir = kwargs.pop("mkdir")
816+
if credential_provider:
817+
msg = "LocalStore does not accept a credential provider"
818+
raise BaseError(msg)
816819

817820
return LocalStore.from_url(
818821
url,

tests/store/test_from_url.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
from __future__ import annotations
2+
13
from pathlib import Path
4+
from typing import TYPE_CHECKING
25

36
import pytest
47

58
from obstore.exceptions import BaseError, UnknownConfigurationKeyError
69
from obstore.store import from_url
710

11+
if TYPE_CHECKING:
12+
from obstore.store import S3Credential
13+
814

915
def test_local():
1016
cwd = Path().absolute()
@@ -55,3 +61,11 @@ def test_http():
5561

5662
with pytest.raises(BaseError):
5763
from_url(url, bucket="test")
64+
65+
66+
def test_credential_provider_to_http_store_raises():
67+
def s3_credential_provider() -> S3Credential:
68+
return {"access_key_id": "", "secret_access_key": "", "expires_at": None}
69+
70+
with pytest.raises(BaseError):
71+
from_url("http://mydomain/path", credential_provider=s3_credential_provider)

0 commit comments

Comments
 (0)