{"record":{"id":"05d3f51bb103b323","repo":"reflex-dev/reflex","slug":"invalid-type-for-environment-variable-field-name","errorCode":null,"errorMessage":"Invalid type for environment variable {field_name}: {field_type}. This is probably an issue in Reflex.","messagePattern":"Invalid type for environment variable (.+?): (.+?)\\. This is probably an issue in Reflex\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"packages/reflex-base/src/reflex_base/environment.py","lineNumber":391,"sourceCode":"            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        ]\n    if isinstance(field_type, type) and issubclass(field_type, enum.Enum):\n        return interpret_enum_env(value, field_type, field_name)\n\n    msg = f\"Invalid type for environment variable {field_name}: {field_type}. This is probably an issue in Reflex.\"\n    raise ValueError(msg)\n\n\nT = TypeVar(\"T\")\n\n\nclass EnvVar(Generic[T]):\n    \"\"\"Environment variable.\"\"\"\n\n    name: str\n    default: Any\n    type_: T\n\n    def __init__(self, name: str, default: Any, type_: T) -> None:\n        \"\"\"Initialize the environment variable.\n\n        Args:\n            name: The environment variable name.\n            default: The default value.","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/environment.py#L373-L409","documentation":"interpret_env_var_value exhausted its type dispatch (str, bool, LogLevel, int, float, Path, enums, sequences, unions, literals...) and hit a field annotation it cannot handle, so it raises ValueError stating 'This is probably an issue in Reflex.' It indicates an annotation the env-parsing layer doesn't support rather than a user value problem.","triggerScenarios":"Annotating an env-parsed dataclass field with an unsupported type such as dict[str, int], a custom class, date, or a generic alias the dispatcher doesn't special-case.","commonSituations":"Adding richly-typed fields to config dataclasses, or upgrading Reflex where a previously tolerated annotation is no longer routed to an interpreter.","solutions":["Change the field annotation to a supported primitive (str, int, float, bool, Path, enum, Literal, Sequence, unions of these) and parse complex types yourself","If the annotation looks like it should be supported, report/check the Reflex issue tracker — the message itself flags a possible framework bug","As a workaround, read the raw str and validate in __post_init__"],"exampleFix":"# before\n@dataclasses.dataclass\nclass Settings:\n    limits: dict[str, int] = ...  # unsupported\n# after\n@dataclasses.dataclass\nclass Settings:\n    limits_raw: str = \"\"  # 'a=1,b=2'\n    @property\n    def limits(self) -> dict[str, int]:\n        return {k: int(v) for k, v in (p.split('=') for p in self.limits_raw.split(',') if p)}\n","handlingStrategy":"type-guard","validationCode":"SUPPORTED = {str, bool, int, float, Path}\nassert field_annotation in SUPPORTED or hasattr(field_annotation, \"__args__\"), f\"unsupported env field type: {field_annotation}\"","typeGuard":"def is_supported_env_type(t) -> bool:\n    import enum, typing\n    return (t in {str, bool, int, float, Path}\n            or (isinstance(t, type) and issubclass(t, enum.Enum))\n            or typing.get_origin(t) is not None)","tryCatchPattern":"null","preventionTips":["Restrict env-parsed fields to primitives; parse complex types manually","Report genuinely unsupported core types upstream — the error flags a possible Reflex bug"],"tags":["environment","type-validation","internal","config"],"backgroundTag":"unsupported-type-annotation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}