{"record":{"id":"2ad8969c6a3afd99","repo":"langchain-ai/deepagents","slug":"key-must-be-a-non-negative-integer","errorCode":null,"errorMessage":"{key} must be a non-negative integer","messagePattern":"(.+?) must be a non-negative integer","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/talon/deepagents_talon/data_lifecycle.py","lineNumber":130,"sourceCode":"    if not root.exists():\n        return\n\n    for path in sorted((item for item in root.rglob(\"*\") if item.is_dir()), reverse=True):\n        try:\n            path.rmdir()\n        except OSError:\n            continue\n\n\ndef _env_non_negative_int(config: TalonConfig, key: str, default: int) -> int:\n    value = config.env.get(key)\n    if value is None:\n        return default\n    try:\n        parsed = int(value)\n    except ValueError as error:\n        msg = f\"{key} must be a non-negative integer\"\n        raise ValueError(msg) from error\n    if parsed < 0:\n        msg = f\"{key} must be a non-negative integer\"\n        raise ValueError(msg)\n    return parsed\n\n\ndef _coerce_utc(value: datetime) -> datetime:\n    if value.tzinfo is None:\n        return value.replace(tzinfo=UTC)\n    return value.astimezone(UTC)\n","sourceCodeStart":112,"sourceCodeEnd":141,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/talon/deepagents_talon/data_lifecycle.py#L112-L141","documentation":"ValueError raised by `_env_non_negative_int` in libs/talon/deepagents_talon/data_lifecycle.py when an environment variable used by `cleanup_sensitive_state` cannot be parsed as an int. The raw string is passed to `int()` and a ValueError is chained into this error with the variable key in the message. It guards configuration supplied via the environment.","triggerScenarios":"Setting a data-lifecycle env var (e.g. a retention/interval setting consumed by `cleanup_sensitive_state`) to a non-numeric string like 'soon', '1h', or '10m' instead of a plain integer.","commonSituations":"Putting unit suffixes in env vars ('30m', '2h') when the code expects raw integers; typos or accidental quotes/whitespace in .env files; shell exporting '300 seconds'.","solutions":["Set the env var to a plain non-negative integer (e.g. `RETENTION_MINUTES=30`), not '30m'.","If the value has units, convert to the base integer unit yourself before setting it.","Check .env files and shell exports for quotes, spaces, or suffix characters around the number."],"exampleFix":"// before\nexport CLEANUP_INTERVAL=30m\n// after\nexport CLEANUP_INTERVAL=30","handlingStrategy":"validation","validationCode":"raw = os.environ.get(\"CLEANUP_INTERVAL\")\nif raw is not None and not raw.strip().lstrip(\"+\").isdecimal():\n    raise ValueError(f\"CLEANUP_INTERVAL must be a non-negative integer, got {raw!r}\")","typeGuard":null,"tryCatchPattern":"try:\n    cleanup_sensitive_state()\nexcept ValueError as exc:\n    logger.error(\"data lifecycle env config invalid: %s\", exc)\n    raise SystemExit(f\"fix env: {exc}\") from exc","preventionTips":["Env vars for this API are plain integers — no unit suffixes like '30m'.","Keep .env values unquoted and free of whitespace.","Parse units yourself and export the base integer."],"tags":["env","configuration","integer-parsing","data-lifecycle"],"backgroundTag":"invalid-env-var-format","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}