assafelovic/gpt-researcher · error · ValueError
Cannot convert {env_value} to list
Error message
Cannot convert {env_value} to list What it means
For list-typed config attributes, convert_env_value parses the env string with json_repair; if parsing raises (first site) this error is raised chained from the parse exception.
Source
Thrown at gpt_researcher/config/config.py:293
except ValueError:
continue
raise ValueError(f"Cannot convert {env_value} to any of {args}")
if type_hint is bool:
return env_value.lower() in ("true", "1", "yes", "on")
elif type_hint is int:
return int(env_value)
elif type_hint is float:
return float(env_value)
elif type_hint in (str, Any):
return env_value
elif type_hint is list or origin is list or origin is List:
# 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"] = verboseView on GitHub (pinned to 6f998577d5)
Solutions
- Provide a JSON array: MYLIST='["a","b"]'
- If you meant a path/string setting, move the value to the correct scalar variable
Example fix
# before SUBQUERIES=one two three # after SUBQUERIES=["one","two","three"]
Defensive patterns
Strategy: validation
Validate before calling
import json
v = os.getenv("MY_LIST", "[]")
try:
assert isinstance(json.loads(v), list)
except Exception:
raise SystemExit(f"MY_LIST must be a JSON array, got {v!r}") Type guard
def is_json_list(s: str) -> bool:
try:
return isinstance(json_repair.loads(s), list)
except Exception:
return False Try / catch
try:
cfg = Config()
except ValueError as e:
if "to list" in str(e):
os.environ["MY_LIST"] = "[]"; cfg = Config()
else: raise Prevention
- Write list env vars as JSON arrays
- Quote arrays in single quotes in .env
When it happens
Trigger: A list-typed env var containing text json_repair cannot recover, e.g. DOC_PATH='just some words' where a JSON array was expected.
Common situations: Free-form text in a list env var; mismatched brackets; wrong var name putting a scalar value on a list field.
Related errors
- Cannot convert {env_value} to dict
- 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
AI-assisted analysis of assafelovic/gpt-researcher@6f998577d5 (2026-08-28).
Data as JSON: /api/errors/336d19af71621f35.
Report an issue: GitHub.