File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,7 +39,11 @@ def normalize_headers(
3939
4040
4141def parse_headers_env_json (raw_headers : Optional [str ]) -> Optional [Dict [str , str ]]:
42- if raw_headers is None or not raw_headers .strip ():
42+ if raw_headers is None :
43+ return None
44+ if not isinstance (raw_headers , str ):
45+ raise HyperbrowserError ("HYPERBROWSER_HEADERS must be a string" )
46+ if not raw_headers .strip ():
4347 return None
4448 try :
4549 parsed_headers = json .loads (raw_headers )
Original file line number Diff line number Diff line change @@ -36,6 +36,13 @@ def test_parse_headers_env_json_ignores_blank_values():
3636 assert parse_headers_env_json (" " ) is None
3737
3838
39+ def test_parse_headers_env_json_rejects_non_string_input ():
40+ with pytest .raises (
41+ HyperbrowserError , match = "HYPERBROWSER_HEADERS must be a string"
42+ ):
43+ parse_headers_env_json (123 ) # type: ignore[arg-type]
44+
45+
3946def test_parse_headers_env_json_rejects_invalid_json ():
4047 with pytest .raises (
4148 HyperbrowserError , match = "HYPERBROWSER_HEADERS must be valid JSON object"
You can’t perform that action at this time.
0 commit comments