Skip to content

Commit 1383530

Browse files
Ignore blank HYPERBROWSER_HEADERS environment values
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent d23b683 commit 1383530

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

hyperbrowser/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def from_env(cls) -> "ClientConfig":
5252
)
5353
headers = None
5454
raw_headers = os.environ.get("HYPERBROWSER_HEADERS")
55-
if raw_headers:
55+
if raw_headers is not None and raw_headers.strip():
5656
try:
5757
parsed_headers = json.loads(raw_headers)
5858
except json.JSONDecodeError as exc:

tests/test_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ def test_client_config_from_env_rejects_non_object_headers_json(monkeypatch):
6262
ClientConfig.from_env()
6363

6464

65+
def test_client_config_from_env_ignores_blank_headers(monkeypatch):
66+
monkeypatch.setenv("HYPERBROWSER_API_KEY", "test-key")
67+
monkeypatch.setenv("HYPERBROWSER_HEADERS", " ")
68+
69+
config = ClientConfig.from_env()
70+
71+
assert config.headers is None
72+
73+
6574
def test_client_config_from_env_normalizes_base_url(monkeypatch):
6675
monkeypatch.setenv("HYPERBROWSER_API_KEY", "test-key")
6776
monkeypatch.setenv("HYPERBROWSER_BASE_URL", " https://example.local/ ")

0 commit comments

Comments
 (0)