assafelovic/gpt-researcher · error · ValueError
Unsupported type {type_hint} for key {key}
Error message
Unsupported type {type_hint} for key {key} What it means
convert_env_value handles bool, int, float, str, list, dict and None; any other type hint (or a value that doesn't fit the str branch) falls to the final else and raises 'Unsupported type ... for key ...'.
Source
Thrown at gpt_researcher/config/config.py:306
# Env values are often hand-edited (trailing commas, single quotes).
# Bare `list` has get_origin(None); typing.List[...] has origin list.
try:
value = json_repair.loads(env_value)
except Exception as exc:
raise ValueError(f"Cannot convert {env_value} to list") from exc
if not isinstance(value, list):
raise ValueError(f"Cannot convert {env_value} to list")
return value
elif type_hint is dict:
try:
value = json_repair.loads(env_value)
except Exception as exc:
raise ValueError(f"Cannot convert {env_value} to dict") from exc
if not isinstance(value, dict):
raise ValueError(f"Cannot convert {env_value} to dict")
return value
else:
raise ValueError(f"Unsupported type {type_hint} for key {key}")
def set_verbose(self, verbose: bool) -> None:
"""Set the verbosity level."""
self.llm_kwargs["verbose"] = verbose
def get_mcp_server_config(self, name: str) -> dict:
"""
Get the configuration for an MCP server.
Args:
name (str): The name of the MCP server to get the config for.
Returns:
dict: The server configuration, or an empty dict if the server is not found.
"""
if not name or not self.mcp_servers:
return {}View on GitHub (pinned to 6f998577d5)
Solutions
- Change the attribute's annotation to a supported type (str/int/float/bool/list/dict)
- Set the value programmatically instead of via env var
- Report/patch convert_env_value to support the type
Example fix
# before my_field: set[str] # env conversion raises # after my_field: list[str]
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = (bool, int, float, str, list, dict, type(None))
# when subclassing/patching Config, check annotations:
for k, t in Config.__annotations__.items():
assert t in SUPPORTED or str(t).startswith('typing'), f"unsupported {k}: {t}" Try / catch
try:
cfg = Config()
except ValueError as e:
if "Unsupported type" in str(e):
# set programmatically instead of env
cfg = Config(); setattr(cfg, key, value)
else: raise Prevention
- Annotate custom Config fields with supported primitives
- Set exotic values in code, not env
When it happens
Trigger: A Config attribute annotated with an exotic type (set, custom class, tuple) whose matching env var is set, so conversion is attempted; typically surfaces after library changes introduce new annotations.
Common situations: Version drift: your fork adds a typed attribute without updating convert_env_value; passing nested typed structures via env.
Related errors
- Cannot convert {env_value} to any of {args}
- Embedding provider not found.
- Invalid retriever(s) found: {', '.join(invalid_retrievers)}.
- Set SMART_LLM or FAST_LLM = '<llm_provider>:<llm_model>' Eg
- Invalid reasoning effort: {reasoning_effort_str}. Valid opti
AI-assisted analysis of assafelovic/gpt-researcher@6f998577d5 (2026-08-28).
Data as JSON: /api/errors/f3aa6f433f55c38d.
Report an issue: GitHub.