{"record":{"id":"051effc082dcbddf","repo":"HumanSignal/label-studio","slug":"environment-variable-key-must-be-an-integer-got","errorCode":null,"errorMessage":"Environment variable {key} must be an integer, got: {value}","messagePattern":"Environment variable (.+?) must be an integer, got: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"label_studio/core/utils/params.py","lineNumber":137,"sourceCode":"                return bool_from_request(os.environ, env_key, default)\n            else:\n                return value\n    return default\n\n\ndef has_env(name: str) -> bool:\n    \"\"\"Return True if any supported environment variable name is set for ``name``.\"\"\"\n    return any((prefix + name) in os.environ for prefix in ('LABEL_STUDIO_', 'HEARTEX_', ''))\n\n\ndef get_int_env(key, default=None):\n    value = get_env(key)\n    if value is None:\n        return default\n    try:\n        return int(value)\n    except ValueError:\n        raise ValueError(f'Environment variable {key} must be an integer, got: {value}')\n\n\ndef get_bool_env(key, default):\n    return get_env(key, default, is_bool=True)\n\n\nT = TypeVar('T')\n\n\ndef get_env_list(\n    key: str, default: Optional[Sequence[T]] = None, value_transform: Callable[[str], T] = str\n) -> Sequence[T]:\n    \"\"\"\n    \"foo,bar,baz\" in env variable => [\"foo\", \"bar\", \"baz\"] in python.\n    Use value_transform to convert the strings to any other type.\n    \"\"\"\n    value = get_env(key)\n    if not value:","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/core/utils/params.py#L119-L155","documentation":"get_int_env reads an environment variable via get_env and coerces it to int. If the variable is set but its value cannot be parsed by int(), it raises ValueError with this message. This fails fast at startup for misconfigured integer environment settings.","triggerScenarios":"Setting an env var consumed by get_int_env (e.g. LABEL_STUDIO_* integer settings) to a non-integer string like 'abc', '10s', or '10.5'.","commonSituations":"Docker/Kubernetes compose files with typo'd values; durations written with units ('300s'); decimals where ints are required; stray quotes or whitespace in .env files that survive parsing.","solutions":["Fix the environment variable to a plain integer string, e.g. LABEL_STUDIO_SOME_LIMIT=300.","Remove units and decimals: '300s' → '300', '10.5' → '10'.","Check .env/secret managers for stray quotes or trailing spaces in the value.","Unset the variable so the documented default applies if you did not intend to override it."],"exampleFix":"// before (docker-compose.yml)\n- LABEL_STUDIO_TASK_FETCH_POOL_SIZE=10x\n\n// after\n- LABEL_STUDIO_TASK_FETCH_POOL_SIZE=10","handlingStrategy":"validation","validationCode":"import os\ndef ensure_int_env(key):\n    value = os.environ.get(key)\n    if value is not None:\n        int(value)  # raises ValueError early with a clear message","typeGuard":"def is_int_str(value) -> bool:\n    try:\n        int(value)\n        return True\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":"try:\n    pool_size = get_int_env('LABEL_STUDIO_TASK_FETCH_POOL_SIZE', 10)\nexcept ValueError as e:\n    logging.error('Bad env config: %s', e)\n    raise SystemExit(1)","preventionTips":["Lint CI/CD and docker-compose env values with a schema check at startup","Never write units or decimals into integer env vars","Beware of quotes/whitespace injected by .env loaders and secret managers"],"tags":["environment-variables","configuration","integer-parsing","startup"],"backgroundTag":"invalid-env-var-value","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}