reflex-dev/reflex · error · ConfigError

default_color_mode must be one of {allowed_color_modes}, but

Error message

default_color_mode must be one of {allowed_color_modes}, but got {self.default_color_mode!r}.

What it means

`rx.Config(default_color_mode=...)` only accepts the values in `LiteralColorMode` (typically `"light"`, `"dark"`, `"system"`). Any other string raises a ConfigError at app startup.

Source

Thrown at packages/reflex-base/src/reflex_base/config.py:423

        # Publish for State-class creation so it never re-enters get_config()
        # (which AttributeErrors if a State is defined while rxconfig.py is mid-import).
        global _state_auto_setters
        _state_auto_setters = self.state_auto_setters

        if (
            self.state_manager_mode == constants.StateManagerMode.REDIS
            and not self.redis_url
        ):
            msg = f"{self._prefixes[0]}REDIS_URL is required when using the redis state manager."
            raise ConfigError(msg)

        allowed_color_modes = constants.LiteralColorMode.__args__
        if self.default_color_mode not in allowed_color_modes:
            msg = (
                f"default_color_mode must be one of "
                f"{allowed_color_modes}, but got {self.default_color_mode!r}."
            )
            raise ConfigError(msg)

    def _normalize_plugins(self):
        """Normalize ``plugins`` entries to Plugin instances.

        Auto-instantiates Plugin subclasses passed without parentheses (e.g.
        ``plugins=[SitemapPlugin]``) so they behave the same as
        ``plugins=[SitemapPlugin()]``. Any entry that is neither a Plugin
        subclass nor a Plugin instance raises ``ConfigError`` with a message
        that names the offending value, instead of failing later in the
        compiler with a confusing ``TypeError`` about a missing ``self``.

        An ``_InvalidPlugin`` (produced when a ``REFLEX_PLUGINS`` import path
        cannot be resolved) is fatal here: ``plugins`` is an explicit list of
        plugins the app needs, so a bad entry raises ``InvalidPluginConfigError``
        and the app cannot start.

        Raises:
            ConfigError: If an entry is neither a Plugin instance nor subclass.

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Use one of the exact values printed in the error, e.g. `"system"`
  2. Check the allowed list in the message and fix casing

Example fix

# before
rx.Config(default_color_mode="auto")

# after
rx.Config(default_color_mode="system")
Defensive patterns

Strategy: validation

Validate before calling

from reflex_base.constants import LiteralColorMode
import typing

def valid_color_mode(v: str) -> str:
    assert v in typing.get_args(LiteralColorMode), f"bad color mode {v!r}"
    return v

rx.Config(default_color_mode=valid_color_mode(mode))

Type guard

from reflex_base.constants import LiteralColorMode
import typing

def is_valid_color_mode(v) -> bool:
    return v in typing.get_args(LiteralColorMode)

Prevention

When it happens

Trigger: `rx.Config(default_color_mode="Light")` (wrong case) or `default_color_mode="auto"` — values not in the literal set.

Common situations: Typos/case mismatches, or assuming a value like `"auto"` from other libraries; also copying config across Reflex versions where allowed values changed.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28). Data as JSON: /api/errors/320868479845fe59. Report an issue: GitHub.