{"record":{"id":"c004def696f36e7f","repo":"reflex-dev/reflex","slug":"invalid-toml-file-format-at-pyproject-path-expe-c004de","errorCode":null,"errorMessage":"Invalid TOML file format at {pyproject_path}. Expected 'tool' to be a dictionary.","messagePattern":"Invalid TOML file format at (.+?)\\. Expected 'tool' to be a dictionary\\.","errorType":"validation","errorClass":"ConfigError","httpStatus":null,"severity":"error","filePath":"packages/reflex-hosting-cli/src/reflex_cli/core/config.py","lineNumber":267,"sourceCode":"        if not pyproject_path.exists():\n            raise ConfigError(f\"Config file not found at {pyproject_path}.\")\n\n        try:\n            import tomllib\n        except ImportError as e:\n            raise ConfigError(\n                \"TOML support is not available. Please use Python 3.11 or later.\"\n            ) from e\n\n        with pyproject_path.open(\"rb\") as file:\n            pyproject_data = tomllib.load(file)\n            if not isinstance(pyproject_data, dict):\n                raise ConfigError(\n                    f\"Invalid TOML file format at {pyproject_path}. Expected a dictionary.\"\n                )\n            tools = pyproject_data.get(\"tool\", {})\n            if not isinstance(tools, dict):\n                raise ConfigError(\n                    f\"Invalid TOML file format at {pyproject_path}. Expected 'tool' to be a dictionary.\"\n                )\n            if \"reflex-cloud\" not in tools:\n                raise ConfigError(\n                    f\"Invalid TOML file format at {pyproject_path}. Expected 'tool.reflex-cloud' to be present.\"\n                )\n            data = tools[\"reflex-cloud\"]\n            if env:\n                data = data.get(\"env\", {}).get(env, {})\n            data = cls._filter_dict(data)\n        return cls(_cloud_config_path=pyproject_path, **data)\n\n    @classmethod\n    def from_yaml_or_toml_or_default(cls) -> Config:\n        \"\"\"Creates a Config instance from either a YAML or TOML file, or returns a default instance.\n\n        Returns:\n            Config: A Config instance with values from the YAML or TOML file, or a default instance if neither file exists.","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-hosting-cli/src/reflex_cli/core/config.py#L249-L285","documentation":"ConfigError raised when the top-level `tool` key in pyproject.toml is not a table. The CLI reads settings from [tool.reflex-cloud], so `tool` must be a dict for the lookup to proceed.","triggerScenarios":"CloudConfig.from_toml where pyproject.toml defines `tool` as a scalar or array, e.g. `tool = \"x\"` or `tool = [\"a\"]`.","commonSituations":"Hand-editing pyproject.toml and assigning a value to `tool` instead of a [tool.*] table; a broken merge or template producing invalid structure.","solutions":["Replace the `tool = ...` assignment with proper TOML tables: [tool.reflex-cloud] and other [tool.x] sections","Run a TOML linter / `tomllib` parse check over pyproject.toml","Recreate the file from a known-good Reflex project template"],"exampleFix":"# before (pyproject.toml)\ntool = [\"reflex-cloud\"]\n\n# after\n[tool.reflex-cloud]\nteardown_on_delete = true","handlingStrategy":"validation","validationCode":"import tomllib\nparsed = tomllib.loads(Path(\"pyproject.toml\").read_text())\nif not isinstance(parsed.get(\"tool\"), dict):\n    raise ValueError(\"'tool' must be a TOML table, e.g. [tool.reflex-cloud]\")","typeGuard":"def has_tool_table(parsed: dict) -> bool:\n    return isinstance(parsed.get(\"tool\"), dict)","tryCatchPattern":"try:\n    config = CloudConfig.from_toml(p)\nexcept ConfigError as e:\n    if \"'tool' to be a dictionary\" in str(e):\n        fix_tool_section(p)  # convert `tool = ...` to [tool.*] tables\n    else:\n        raise","preventionTips":["Never assign a scalar/array to the `tool` key; always use [tool.x] table syntax","Lint pyproject.toml after structural edits"],"tags":["config","toml","format","reflex-hosting-cli"],"backgroundTag":"config-format-invalid","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}