{"record":{"id":"59cfdce64ea88927","repo":"langchain-ai/deepagents","slug":"max-media-bytes-env-must-be-a-positive-integer-b","errorCode":null,"errorMessage":"{MAX_MEDIA_BYTES_ENV} must be a positive integer byte count","messagePattern":"(.+?) must be a positive integer byte count","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/talon/deepagents_talon/channels/base.py","lineNumber":346,"sourceCode":"    \"\"\"Return the configured global media cap.\n\n    Args:\n        env: Environment variable mapping.\n\n    Returns:\n        Maximum media bytes allowed for channel media.\n\n    Raises:\n        ValueError: If the configured value is not a positive integer.\n    \"\"\"\n    value = env.get(MAX_MEDIA_BYTES_ENV)\n    if value is None:\n        return DEFAULT_MAX_MEDIA_BYTES\n    msg = f\"{MAX_MEDIA_BYTES_ENV} must be a positive integer byte count\"\n    try:\n        parsed = int(value)\n    except ValueError as error:\n        raise ValueError(msg) from error\n    if parsed < 1:\n        raise ValueError(msg)\n    return parsed\n\n\ndef parse_float(value: str | None, default: float) -> float:\n    \"\"\"Parse an optional float value with a default.\n\n    Args:\n        value: Raw environment value.\n        default: Value returned when `value` is missing.\n\n    Returns:\n        Parsed float.\n\n    Raises:\n        ValueError: If `value` is not a float.\n    \"\"\"","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/talon/deepagents_talon/channels/base.py#L328-L364","documentation":"`max_media_bytes_from_env` parses `DEEPAGENTS_TALON_MAX_MEDIA_BYTES`; when the value cannot be converted with `int()`, it raises this ValueError with a message naming the env var. The function requires a positive integer byte count or falls back to the default.","triggerScenarios":"Setting `DEEPAGENTS_TALON_MAX_MEDIA_BYTES` to a non-numeric string (e.g. `'1GB'`, `'500 MB'`, `''` treated as value, `'10_000'` with unsupported separator in some locales) and calling `max_media_bytes_from_env` from `from_talon_config`.","commonSituations":"Writing human-readable sizes like `1GB` or `100MiB` instead of raw byte counts; stray whitespace/quotes from .env files; copy-paste with a thousands comma like `1,073,741,824`.","solutions":["Set a plain positive integer of bytes, e.g. `DEEPAGENTS_TALON_MAX_MEDIA_BYTES=1073741824` for 1 GiB.","Remove the variable entirely to use the default (1 GiB).","Catch the ValueError at startup and fail fast with a clear config error."],"exampleFix":"# before\nDEEPAGENTS_TALON_MAX_MEDIA_BYTES=1GB\n\n# after\nDEEPAGENTS_TALON_MAX_MEDIA_BYTES=1073741824","handlingStrategy":"validation","validationCode":"import os, re\nraw = os.environ.get('DEEPAGENTS_TALON_MAX_MEDIA_BYTES')\nif raw is not None and not re.fullmatch(r'[0-9]+', raw.strip()):\n    raise SystemExit('DEEPAGENTS_TALON_MAX_MEDIA_BYTES must be a positive integer byte count')","typeGuard":null,"tryCatchPattern":"try:\n    cap = max_media_bytes_from_env(os.environ)\nexcept ValueError as exc:\n    raise SystemExit(f'invalid media cap config: {exc}') from exc","preventionTips":["Write raw byte counts (e.g. 1073741824), never '1GB'.","Add a CI/startup lint that checks numeric env vars match `-?[0-9]+`.","Document the variable's unit (bytes) next to where it is set."],"tags":["config","env","validation"],"backgroundTag":"invalid-env-var-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}