{"record":{"id":"313ea89c5fcddee6","repo":"headroomlabs-ai/headroom","slug":"body-too-large-status-env-must-be-an-integer-go","errorCode":null,"errorMessage":"{BODY_TOO_LARGE_STATUS_ENV} must be an integer, got {raw!r}","messagePattern":"(.+?) must be an integer, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"headroom/proxy/request_limit_policy.py","lineNumber":32,"sourceCode":"    if raw is None or raw == \"\":\n        return SSE_EVENT_MAX_BYTES_DEFAULT\n    try:\n        value = int(raw)\n    except ValueError as exc:\n        raise ValueError(f\"{SSE_EVENT_MAX_BYTES_ENV} must be an integer, got {raw!r}\") from exc\n    if value <= 0:\n        raise ValueError(f\"{SSE_EVENT_MAX_BYTES_ENV} must be positive, got {value}\")\n    return value\n\n\ndef resolve_body_too_large_status(raw: str | None) -> int:\n    \"\"\"Resolve the HTTP status code for body-too-large rejections.\"\"\"\n    if raw is None or raw == \"\":\n        return BODY_TOO_LARGE_STATUS_DEFAULT\n    try:\n        value = int(raw)\n    except ValueError as exc:\n        raise ValueError(f\"{BODY_TOO_LARGE_STATUS_ENV} must be an integer, got {raw!r}\") from exc\n    if not 400 <= value < 600:\n        raise ValueError(f\"{BODY_TOO_LARGE_STATUS_ENV} must be a 4xx/5xx status, got {value}\")\n    return value\n","sourceCodeStart":14,"sourceCodeEnd":36,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/proxy/request_limit_policy.py#L14-L36","documentation":"resolve_body_too_large_status parses HEADROOM_PROXY_BODY_TOO_LARGE_STATUS and requires an integer HTTP status string. Non-integer values like '413.0', 'Payload Too Large', or '4xx' fail int() and raise with the raw value. Unset or empty returns the default 413.","triggerScenarios":"Setting HEADROOM_PROXY_BODY_TOO_LARGE_STATUS to a reason phrase, float, or typo like '14'.","commonSituations":"Copy-pasting HTTP reason phrases; configs migrated from tools that accept symbolic statuses.","solutions":["Use a numeric status code such as 413 or 400.","Unset the variable to keep the default 413.","Remove quotes around numeric values in env files if a parser stores '413' correctly but letters do not."],"exampleFix":"# before\nexport HEADROOM_PROXY_BODY_TOO_LARGE_STATUS=Payload Too Large\n\n# after\nexport HEADROOM_PROXY_BODY_TOO_LARGE_STATUS=413","handlingStrategy":"validation","validationCode":"raw = os.environ.get(\"HEADROOM_PROXY_BODY_TOO_LARGE_STATUS\")\nif raw not in (None, \"\"):\n    try:\n        int(raw)\n    except ValueError:\n        raise SystemExit(\"BODY_TOO_LARGE_STATUS must be numeric\")","typeGuard":"def parses_as_int(raw: str | None) -> bool:\n    if raw in (None, \"\"):\n        return True\n    try:\n        int(raw)\n        return True\n    except ValueError:\n        return False","tryCatchPattern":"from headroom.proxy.request_limit_policy import resolve_body_too_large_status\ntry:\n    status = resolve_body_too_large_status(raw)\nexcept ValueError as e:\n    abort_with(e)","preventionTips":["Use numeric status codes only (413 is the default).","Document that reason phrases are unsupported."],"tags":["env","validation","http"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}