{"record":{"id":"ab4f8305c46bdebc","repo":"TauricResearch/TradingAgents","slug":"expected-a-boolean-join-bool-true-bool-f","errorCode":null,"errorMessage":"expected a boolean ({'/'.join(_BOOL_TRUE + _BOOL_FALSE)}), got {value!r}","messagePattern":"expected a boolean \\((.+?)\\), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tradingagents/default_config.py","lineNumber":48,"sourceCode":"\n_BOOL_TRUE = (\"true\", \"1\", \"yes\", \"on\")\n_BOOL_FALSE = (\"false\", \"0\", \"no\", \"off\")\n\n\ndef _coerce(value: str, reference):\n    \"\"\"Coerce env-var string to the type of the existing default value.\n\n    Invalid values raise ``ValueError`` rather than silently falling back to a\n    default — a misspelled boolean (e.g. ``treu``) or non-numeric int should fail\n    loudly at startup, not quietly misconfigure an unattended run.\n    \"\"\"\n    if isinstance(reference, bool):\n        normalized = value.strip().lower()\n        if normalized in _BOOL_TRUE:\n            return True\n        if normalized in _BOOL_FALSE:\n            return False\n        raise ValueError(\n            f\"expected a boolean ({'/'.join(_BOOL_TRUE + _BOOL_FALSE)}), got {value!r}\"\n        )\n    if isinstance(reference, int) and not isinstance(reference, bool):\n        return int(value)\n    if isinstance(reference, float):\n        return float(value)\n    return value\n\n\ndef _apply_env_overrides(config: dict) -> dict:\n    \"\"\"Apply TRADINGAGENTS_* env vars to the config dict in-place.\"\"\"\n    for env_var, key in _ENV_OVERRIDES.items():\n        raw = os.environ.get(env_var)\n        if raw is None or raw == \"\":\n            continue\n        try:\n            config[key] = _coerce(raw, config.get(key))\n        except ValueError as exc:","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/TauricResearch/TradingAgents/blob/a33fd4c0f134485a43553a2c23a63cb14adbd88f/tradingagents/default_config.py#L30-L66","documentation":"ValueError raised by _coerce in tradingagents/default_config.py when a TRADINGAGENTS_* env var mapped to a boolean config key holds a string that is not in the accepted true/false sets. Invalid values fail loudly at startup instead of silently falling back — a misspelled 'treu' would otherwise misconfigure an unattended run.","triggerScenarios":"Setting a boolean env var (e.g. TRADINGAGENTS_BACKEND_URL-check style boolean keys) to a non-recognized spelling such as 'treu', 'yes', '1', or 'enabled' — anything not in the _BOOL_TRUE/_BOOL_FALSE token sets. _coerce is called from _apply_env_overrides during module import.","commonSituations":"Typos in .env files or CI environment variables; using 'yes'/'no' or '1'/'0' when the library expects 'true'/'false'; shell-exported debug flags with wrong casing or trailing characters.","solutions":["Check the error's accepted token list (the _BOOL_TRUE/_BOOL_FALSE values shown in the message) and use one of those spellings.","Audit your .env / CI secrets for the offending TRADINGAGENTS_* variable and fix the value.","Standardize on lowercase 'true'/'false' for every boolean env var in your deployment."],"exampleFix":"# before\nexport TRADINGAGENTS_DEBUG=treu\n\n# after\nexport TRADINGAGENTS_DEBUG=true","handlingStrategy":"validation","validationCode":"_BOOL_TRUE = {'true', '1', 'yes', 'on'}\n_BOOL_FALSE = {'false', '0', 'no', 'off'}\n\ndef is_valid_bool_env(raw: str | None) -> bool:\n    return raw is None or raw == '' or raw.strip().lower() in _BOOL_TRUE | _BOOL_FALSE\n\nassert is_valid_bool_env('true') and not is_valid_bool_env('treu')","typeGuard":null,"tryCatchPattern":"try:\n    import tradingagents.default_config\nexcept ValueError as e:\n    print(f'config error at import: {e}')  # name the bad TRADINGAGENTS_* var and exit fast\n    raise SystemExit(2)","preventionTips":["Standardize on lowercase 'true'/'false' across your env tooling.","Lint .env files for boolean keys against accepted tokens in CI.","Fail the deploy when import-time validation raises instead of catching and continuing."],"tags":["configuration","environment-variables","validation","startup"],"backgroundTag":null,"analyzedSha":"a33fd4c0f134485a43553a2c23a63cb14adbd88f","analyzedAt":"2026-08-14T19:45:16.920Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}