{"record":{"id":"9a4074747fea2d39","repo":"BerriAI/litellm","slug":"invalid-environment-environment-please-use-one","errorCode":null,"errorMessage":"Invalid environment: {environment}. Please use one of the following instead: {valid_values}","messagePattern":"Invalid environment: (.+?)\\. Please use one of the following instead: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/deepeval/utils.py","lineNumber":14,"sourceCode":"from datetime import datetime, timezone\nfrom typing import Final\n\nfrom litellm.integrations.deepeval.types import Environment\n\n\ndef to_zod_compatible_iso(dt: datetime) -> str:\n    return dt.astimezone(timezone.utc).isoformat(timespec=\"milliseconds\").replace(\"+00:00\", \"Z\")\n\n\ndef validate_environment(environment: str):\n    if environment not in [env.value for env in Environment]:\n        valid_values: Final = \", \".join(f'\"{env.value}\"' for env in Environment)\n        raise ValueError(f\"Invalid environment: {environment}. Please use one of the following instead: {valid_values}\")\n","sourceCodeStart":1,"sourceCodeEnd":15,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/deepeval/utils.py#L1-L15","documentation":"validate_environment (litellm/integrations/deepeval/utils.py) checks LITELM_ENVIRONMENT against the Environment enum, whose only members are \"production\", \"development\", \"staging\" (default is \"development\" when unset). The comparison is exact and case-sensitive, so \"prod\", \"dev\", \"PRODUCTION\", or any custom string raises ValueError during DeepEvalLogger initialization.","triggerScenarios":"Setting LITELM_ENVIRONMENT=prod (common alias) instead of production; capitalized values like Staging; pipeline-injected values such as \"pr-123\" or \"qa\" that don't match the enum; empty-string value also fails the membership test.","commonSituations":"Organizations whose existing DEPLOYMENT_ENV/ENV conventions use prod/dev/qa; CI injecting branch names as environment; case mismatches from copy-pasting docs.","solutions":["Use exactly one of: production, development, staging (lowercase)","Unset LITELM_ENVIRONMENT to fall back to the development default","Map your internal value before it reaches litellm: LITELM_ENVIRONMENT=$(case \"$STAGE\" in prod) echo production;; *) echo development;; esac"],"exampleFix":"# before\nexport LITELM_ENVIRONMENT=prod   # ValueError\n\n# after\nexport LITELM_ENVIRONMENT=production","handlingStrategy":"validation","validationCode":"VALID = {\"production\", \"development\", \"staging\"}\n\ndef litellm_environment_ok() -> bool:\n    import os\n    return os.getenv(\"LITELM_ENVIRONMENT\", \"development\") in VALID\n\ndef normalize_env(value: str | None) -> str:\n    aliases = {\"prod\": \"production\", \"dev\": \"development\", \"stage\": \"staging\"}\n    v = (value or \"development\").lower()\n    return aliases.get(v, v)","typeGuard":"from typing import Any\n\ndef is_valid_environment(value: Any) -> bool:\n    \"\"\"Exact, case-sensitive membership in litellm's Environment enum.\"\"\"\n    return value in (\"production\", \"development\", \"staging\")","tryCatchPattern":null,"preventionTips":["Map internal stage aliases (prod/dev) to the three allowed values before litellm sees them","Add a startup config check that fails fast on unknown LITELM_ENVIRONMENT","Remember unset defaults to development — explicit wrong values are the only failure mode"],"tags":["deepeval","env-var","enum-validation","configuration","case-sensitivity"],"backgroundTag":"invalid-config-value","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}