File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import json
2- from typing import Dict , Mapping , Optional
2+ from typing import Dict , Mapping , Optional , cast
33
44from .exceptions import HyperbrowserError
55
@@ -43,8 +43,12 @@ def parse_headers_env_json(raw_headers: Optional[str]) -> Optional[Dict[str, str
4343 raise HyperbrowserError (
4444 "HYPERBROWSER_HEADERS must be valid JSON object"
4545 ) from exc
46+ if not isinstance (parsed_headers , Mapping ):
47+ raise HyperbrowserError (
48+ "HYPERBROWSER_HEADERS must be a JSON object of string pairs"
49+ )
4650 return normalize_headers (
47- parsed_headers , # type: ignore[arg-type]
51+ cast ( Mapping [ str , str ], parsed_headers ),
4852 mapping_error_message = "HYPERBROWSER_HEADERS must be a JSON object of string pairs" ,
4953 pair_error_message = "HYPERBROWSER_HEADERS must be a JSON object of string pairs" ,
5054 )
You can’t perform that action at this time.
0 commit comments