File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 :
Original file line number Diff line number Diff 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+
6574def 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/ " )
You can’t perform that action at this time.
0 commit comments