{"record":{"id":"5662f24ca08bc01b","repo":"reflex-dev/reflex","slug":"invalid-toml-file-format-at-pyproject-path-expe","errorCode":null,"errorMessage":"Invalid TOML file format at {pyproject_path}. Expected a dictionary.","messagePattern":"Invalid TOML file format at (.+?)\\. Expected a dictionary\\.","errorType":"validation","errorClass":"ConfigError","httpStatus":null,"severity":"error","filePath":"packages/reflex-hosting-cli/src/reflex_cli/core/config.py","lineNumber":262,"sourceCode":"\n        Raises:\n            ConfigError: If the TOML file is not found.\n\n        \"\"\"\n        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","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-hosting-cli/src/reflex_cli/core/config.py#L244-L280","documentation":"ConfigError raised when the parsed TOML file's root is not a mapping. tomllib normally produces a dict, so this guards against degenerate/empty files or unexpected parser output; the CLI requires a table at the root to look up [tool.reflex-cloud].","triggerScenarios":"CloudConfig.from_toml on a pyproject.toml whose parsed root is not a dict (e.g. an effectively empty or malformed file that yields a non-dict).","commonSituations":"A truncated or corrupted pyproject.toml; accidentally pointing the config path at a non-TOML file that parses to a scalar/array.","solutions":["Open the reported file and restore valid TOML table syntax (e.g. [project] ... at minimum)","If the file is not meant to be a TOML config, correct the path passed to from_toml","Regenerate the file from your project template"],"exampleFix":"# before (pyproject.toml)\n\"just a string\"\n\n# after\n[project]\nname = \"my-app\"","handlingStrategy":"validation","validationCode":"import tomllib\nparsed = tomllib.loads(Path(\"pyproject.toml\").read_text())\nif not isinstance(parsed, dict) or not parsed:\n    raise ValueError(\"pyproject.toml root is not a TOML table\")","typeGuard":"def is_toml_table(data) -> bool:\n    return isinstance(data, dict)","tryCatchPattern":"try:\n    config = CloudConfig.from_toml(p)\nexcept ConfigError as e:\n    if \"Expected a dictionary\" in str(e):\n        # rewrite the corrupted file from a template\n        restore_default_pyproject(p)\n    else:\n        raise","preventionTips":["Don't truncate pyproject.toml during edits; validate with a TOML parser afterwards","Keep the file in version control and review diffs before saving"],"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"}