File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class ClientConfig:
1616 @classmethod
1717 def from_env (cls ) -> "ClientConfig" :
1818 api_key = os .environ .get ("HYPERBROWSER_API_KEY" )
19- if api_key is None :
19+ if api_key is None or not api_key . strip () :
2020 raise HyperbrowserError (
2121 "HYPERBROWSER_API_KEY environment variable is required"
2222 )
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ def test_client_config_from_env_raises_hyperbrowser_error_without_api_key(monkey
1111 ClientConfig .from_env ()
1212
1313
14+ def test_client_config_from_env_raises_hyperbrowser_error_for_blank_api_key (monkeypatch ):
15+ monkeypatch .setenv ("HYPERBROWSER_API_KEY" , " " )
16+
17+ with pytest .raises (HyperbrowserError , match = "HYPERBROWSER_API_KEY" ):
18+ ClientConfig .from_env ()
19+
20+
1421def test_client_config_from_env_reads_api_key_and_base_url (monkeypatch ):
1522 monkeypatch .setenv ("HYPERBROWSER_API_KEY" , "test-key" )
1623 monkeypatch .setenv ("HYPERBROWSER_BASE_URL" , "https://example.local" )
You can’t perform that action at this time.
0 commit comments