{"record":{"id":"1aa09ec1b7e76dd6","repo":"reflex-dev/reflex","slug":"invalid-literal-value-value-r-for-field-name","errorCode":null,"errorMessage":"Invalid literal value: {value!r} for {field_name}, expected one of {literal_values}","messagePattern":"Invalid literal value: (.+?) for (.+?), expected one of (.+?)","errorType":"exception","errorClass":"EnvironmentVarValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/environment.py","lineNumber":368,"sourceCode":"        for literal_value in literal_values:\n            if isinstance(literal_value, str) and literal_value == value:\n                return literal_value\n            if isinstance(literal_value, bool):\n                try:\n                    interpreted_bool = interpret_boolean_env(value, field_name)\n                    if interpreted_bool == literal_value:\n                        return interpreted_bool\n                except EnvironmentVarValueError:\n                    continue\n            if isinstance(literal_value, int):\n                try:\n                    interpreted_int = interpret_int_env(value, field_name)\n                    if interpreted_int == literal_value:\n                        return interpreted_int\n                except EnvironmentVarValueError:\n                    continue\n        msg = f\"Invalid literal value: {value!r} for {field_name}, expected one of {literal_values}\"\n        raise EnvironmentVarValueError(msg)\n    # If the field was Annotated with SequenceOptions, extract the options\n    sequence_options = DEFAULT_SEQUENCE_OPTIONS\n    for arg in annotated_metadata:\n        if isinstance(arg, SequenceOptions):\n            sequence_options = arg\n            break\n    if get_origin(field_type) in (list, Sequence):\n        items = value.split(sequence_options.delimiter)\n        if sequence_options.strip:\n            items = [item.strip() for item in items]\n        return [\n            interpret_env_var_value(\n                v,\n                get_args(field_type)[0],\n                f\"{field_name}[{i}]\",\n            )\n            for i, v in enumerate(items)\n        ]","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/environment.py#L350-L386","documentation":"For Literal-typed fields the raw string (and, for int literals, its int() interpretation) must equal one of the Literal's values; otherwise EnvironmentVarValueError is raised listing the allowed values. This is strict equality validation, not fuzzy matching.","triggerScenarios":"Setting a Literal['dev','prod','test'] field to 'production', or a Literal[80, 443] field to '8080'. The code tries the string directly, then int-parses for int literals before failing.","commonSituations":"Env value drift from the allowed set ('production' vs 'prod'), numeric literals passed with units, or new allowed values not present in the pinned Reflex version.","solutions":["Use exactly one of the values shown in the message","For int literals, pass a bare integer string","Check the field's Literal definition if unsure of allowed values"],"exampleFix":"# before\nENV=production  # Literal['dev','prod','test']\n# after\nENV=prod\n","handlingStrategy":"validation","validationCode":"import typing\nallowed = typing.get_args(LiteralType)\nassert raw in allowed or (any(isinstance(a, int) for a in allowed) and raw.lstrip(\"+-\").isdigit() and int(raw) in allowed), f\"must be one of {allowed}\"","typeGuard":"def is_valid_literal(v: str, literal_vals: tuple) -> bool:\n    return v in literal_vals or (v.lstrip(\"+-\").isdigit() and int(v) in literal_vals)","tryCatchPattern":"except EnvironmentVarValueError:\n    raw = allowed[0]  # first literal as fallback","preventionTips":["Mirror allowed Literal values in deployment docs/templates","Add a config lint step comparing env values to Literal sets"],"tags":["environment","literal","validation","config"],"backgroundTag":"env-var-validation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}