reflex-dev/reflex · error · ConfigError

Invalid TOML file format at {pyproject_path}. Expected 'tool

Error message

Invalid TOML file format at {pyproject_path}. Expected 'tool.reflex-cloud' to be present.

What it means

ConfigError raised when the [tool.reflex-cloud] table is absent from pyproject.toml. The TOML loader requires this section to hold the CLI's cloud configuration, so a pyproject.toml without it cannot provide config.

Source

Thrown at packages/reflex-hosting-cli/src/reflex_cli/core/config.py:271

            import tomllib
        except ImportError as e:
            raise ConfigError(
                "TOML support is not available. Please use Python 3.11 or later."
            ) from e

        with pyproject_path.open("rb") as file:
            pyproject_data = tomllib.load(file)
            if not isinstance(pyproject_data, dict):
                raise ConfigError(
                    f"Invalid TOML file format at {pyproject_path}. Expected a dictionary."
                )
            tools = pyproject_data.get("tool", {})
            if not isinstance(tools, dict):
                raise ConfigError(
                    f"Invalid TOML file format at {pyproject_path}. Expected 'tool' to be a dictionary."
                )
            if "reflex-cloud" not in tools:
                raise ConfigError(
                    f"Invalid TOML file format at {pyproject_path}. Expected 'tool.reflex-cloud' to be present."
                )
            data = tools["reflex-cloud"]
            if env:
                data = data.get("env", {}).get(env, {})
            data = cls._filter_dict(data)
        return cls(_cloud_config_path=pyproject_path, **data)

    @classmethod
    def from_yaml_or_toml_or_default(cls) -> Config:
        """Creates a Config instance from either a YAML or TOML file, or returns a default instance.

        Returns:
            Config: A Config instance with values from the YAML or TOML file, or a default instance if neither file exists.

        """
        return cls.from_yaml_or_toml_or_none() or cls()

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Add a [tool.reflex-cloud] section (can be empty) to pyproject.toml
  2. Or ensure rxconfig.yaml exists so from_yaml_or_toml_or_none loads YAML config instead

Example fix

# before (pyproject.toml)
[tool.ruff]
line-length = 100

# after
[tool.ruff]
line-length = 100

[tool.reflex-cloud]
teardown_on_delete = true
Defensive patterns

Strategy: validation

Validate before calling

import tomllib
parsed = tomllib.loads(Path("pyproject.toml").read_text())
if "reflex-cloud" not in parsed.get("tool", {}):
    parsed.setdefault("tool", {})['reflex-cloud'] = {}  # add empty section
# now safe to load

Type guard

def has_reflex_cloud_section(parsed: dict) -> bool:
    return "reflex-cloud" in parsed.get("tool", {})

Try / catch

try:
    config = CloudConfig.from_toml(p)
except ConfigError as e:
    if "tool.reflex-cloud" in str(e):
        add_empty_reflex_cloud_section(p)
        config = CloudConfig.from_toml(p)
    else:
        raise

Prevention

When it happens

Trigger: CloudConfig.from_toml on a pyproject.toml that has a [tool] table (or other tool.* sections) but no [tool.reflex-cloud] entry; env sub-lookup also fails here when the table is missing.

Common situations: Using a generic Python pyproject.toml in a Reflex project without adding the reflex-cloud section; config resolution falling through to TOML when you expected it to use rxconfig.yaml.

Related errors


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