{"record":{"id":"5b7370ac3588b09a","repo":"reflex-dev/reflex","slug":"invalid-enum-value-value-r-for-field-name","errorCode":null,"errorMessage":"Invalid enum value: {value!r} for {field_name}","messagePattern":"Invalid enum value: (.+?) for (.+?)","errorType":"exception","errorClass":"EnvironmentVarValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/environment.py","lineNumber":262,"sourceCode":"def interpret_enum_env(value: str, field_type: GenericType, field_name: str) -> Any:\n    \"\"\"Interpret an enum environment variable value.\n\n    Args:\n        value: The environment variable value.\n        field_type: The field type.\n        field_name: The field name.\n\n    Returns:\n        The interpreted value.\n\n    Raises:\n        EnvironmentVarValueError: If the value is invalid.\n    \"\"\"\n    try:\n        return field_type(value)\n    except ValueError as ve:\n        msg = f\"Invalid enum value: {value!r} for {field_name}\"\n        raise EnvironmentVarValueError(msg) from ve\n\n\n@dataclasses.dataclass(frozen=True, kw_only=True, slots=True)\nclass SequenceOptions:\n    \"\"\"Options for interpreting Sequence environment variables.\"\"\"\n\n    delimiter: str = \":\"\n    strip: bool = False\n\n\nDEFAULT_SEQUENCE_OPTIONS = SequenceOptions()\n\n\ndef interpret_env_var_value(\n    value: str, field_type: GenericType, field_name: str\n) -> Any:\n    \"\"\"Interpret an environment variable value based on the field type.\n","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/environment.py#L244-L280","documentation":"interpret_enum_env constructs the enum type from the raw string via field_type(value); if the string isn't a valid member value, the ValueError is re-raised as EnvironmentVarValueError naming the field. Matching is on enum values, not names (unless the enum aliases them).","triggerScenarios":"Setting an enum-typed env var to a string that is not one of the enum's member values, e.g. LOG_FORMAT=pretty when members are 'json' | 'text'.","commonSituations":"Using an enum member name instead of its value, or values that differ across Reflex versions.","solutions":["Use an exact enum value string (check the enum definition referenced by the field)","If you intended the member name, use the value that member maps to","Pin/verify against the Reflex version's enum members"],"exampleFix":"# before\nLOG_FORMAT=PRETTY  # enum values are 'json','text'\n# after\nLOG_FORMAT=text\n","handlingStrategy":"validation","validationCode":"allowed = {m.value for m in MyEnum}\nassert raw in allowed, f\"must be one of {sorted(allowed)}\"","typeGuard":"def is_valid_enum_value(v: str, enum_cls: type[enum.Enum]) -> bool:\n    return v in {m.value for m in enum_cls}","tryCatchPattern":"except EnvironmentVarValueError:\n    value = MyEnum.DEFAULT  # fallback member","preventionTips":["Keep an env var cheat-sheet mapping each var to its allowed enum values","Prefer enum values that match common usage to reduce mismatch"],"tags":["environment","enum","validation","config"],"backgroundTag":"env-var-validation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}