{"record":{"id":"1627f8adfc1e6a1d","repo":"OpenBB-finance/OpenBB","slug":"failed-to-cast-value-to-bool","errorCode":null,"errorMessage":"Failed to cast {value} to bool.","messagePattern":"Failed to cast (.+?) to bool\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/core/openbb_core/env.py","lineNumber":77,"sourceCode":"        return self.str2bool(\n            self._environ.get(\"OPENBB_ALLOW_MUTABLE_EXTENSIONS\", False)\n        )\n\n    @property\n    def ALLOW_ON_COMMAND_OUTPUT(self) -> bool:\n        \"\"\"Allow on command output: enables extensions that act on command output.\"\"\"\n        return self.str2bool(self._environ.get(\"OPENBB_ALLOW_ON_COMMAND_OUTPUT\", False))\n\n    @staticmethod\n    def str2bool(value) -> bool:\n        \"\"\"Match a value to its boolean correspondent.\"\"\"\n        if isinstance(value, bool):\n            return value\n        if value.lower() in {\"false\", \"f\", \"0\", \"no\", \"n\"}:\n            return False\n        if value.lower() in {\"true\", \"t\", \"1\", \"yes\", \"y\"}:\n            return True\n        raise ValueError(f\"Failed to cast {value} to bool.\")\n","sourceCodeStart":59,"sourceCodeEnd":78,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/core/openbb_core/env.py#L59-L78","documentation":"ValueError from Env.str2bool, which parses OpenBB's boolean environment variables (OPENBB_DEBUG_MODE, OPENBB_ALLOW_ON_COMMAND_OUTPUT, etc.). Accepted values are true/false, t/f, 1/0, yes/no, y/n (case-insensitive); anything else - 'on', 'enabled', '' (empty string from 'set VAR='), or arbitrary text - raises this error at settings load time.","triggerScenarios":"export OPENBB_DEBUG_MODE=on (not accepted), OPENBB_DEBUG_MODE='' after 'set -u' style clearing, or CI injecting OPENBB_DEBUG_MODE enabled. The error surfaces as soon as OpenBB reads its environment (import openbb / first command), because Env properties call str2bool on _environ.get(...).","commonSituations":"Using 'on/off' or 'enabled' boolean conventions from other tools; Docker ENV or docker-compose boolean-ish values; shell scripts exporting empty strings; YAML/Ansible env maps passing values like 'True ' with whitespace or '2'.","solutions":["Use one of the accepted literals: export OPENBB_DEBUG_MODE=true (or false/1/0/yes/no)","Unset the variable entirely instead of setting it empty: unset OPENBB_DEBUG_MODE","Audit docker-compose.yml / CI env blocks for OpenBB variables with non-standard boolean values"],"exampleFix":"# before\nexport OPENBB_DEBUG_MODE=on\npython -c 'import openbb'  # ValueError: Failed to cast on to bool.\n\n# after\nexport OPENBB_DEBUG_MODE=true\npython -c 'import openbb'","handlingStrategy":"validation","validationCode":"TRUE = {'true', 't', '1', 'yes', 'y'}\nFALSE = {'false', 'f', '0', 'no', 'n'}\n\ndef env_bool_ok(val) -> bool:\n    return not isinstance(val, str) or val.lower() in TRUE | FALSE","typeGuard":"def is_openbb_bool(v) -> bool:\n    return not isinstance(v, str) or v.lower() in {'true','t','1','yes','y','false','f','0','no','n'}","tryCatchPattern":"# Raised at import time - catch around import in launchers\ntry:\n    import openbb as obb\nexcept ValueError as e:\n    if 'Failed to cast' in str(e):\n        import os\n        bad = [k for k in os.environ if k.startswith('OPENBB_') and os.environ[k].lower() not in {'true','t','1','yes','y','false','f','0','no','n'}]\n        raise SystemExit(f'Fix OPENBB_* boolean env vars: {bad}') from e\n    raise","preventionTips":["Use only true/false (or 1/0, yes/no) for OPENBB_* booleans","Never set OpenBB env vars to empty strings - unset them instead","Lint docker-compose/CI env maps for OpenBB variables before deploy"],"tags":["openbb","environment","configuration","boolean-parsing"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}