{"record":{"id":"7c092cfaf7454332","repo":"pytest-dev/pytest","slug":"path-exc","errorCode":null,"errorMessage":"{path}: {exc}","messagePattern":"\\{path\\}: \\{exc\\}","errorType":"exception","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/findpaths.py","lineNumber":73,"sourceCode":"    except iniconfig.ParseError as exc:\n        raise UsageError(str(exc)) from exc\n\n\ndef _parse_toml_file(path: Path) -> dict[str, object]:\n    \"\"\"Parse the given '.toml' file, returning the decoded document.\n\n    Raise UsageError if the file cannot be parsed.\n    \"\"\"\n    if sys.version_info >= (3, 11):\n        import tomllib\n    else:\n        import tomli as tomllib\n\n    toml_text = path.read_text(encoding=\"utf-8\")\n    try:\n        return tomllib.loads(toml_text)\n    except tomllib.TOMLDecodeError as exc:\n        raise UsageError(f\"{path}: {exc}\") from exc\n\n\ndef _load_pytest_ini(path: Path) -> ConfigDict | None:\n    \"\"\"Load a dedicated pytest INI file (``pytest.ini``/``.pytest.ini``).\n\n    These files are always the source of configuration, even if they lack a\n    ``[pytest]`` section, in which case an empty config is returned.\n    \"\"\"\n    iniconfig = _parse_ini_config(path)\n\n    if \"pytest\" in iniconfig:\n        return {\n            k: ConfigValue(v, origin=\"file\", mode=\"ini\")\n            for k, v in iniconfig[\"pytest\"].items()\n        }\n    return {}\n\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/findpaths.py#L55-L91","documentation":"pytest raises UsageError when a TOML config file (pyproject.toml or a pytest .toml config) contains syntax that tomllib/tomli cannot parse. The path and the underlying TOMLDecodeError detail are surfaced so the user can locate the malformed line.","triggerScenarios":"Editing pyproject.toml and leaving an unquoted string, mismatched brackets, a duplicate key, or a stray character; saving with an editor that injected BOM or non-UTF-8 bytes; manual merge-conflict residue inside [tool.pytest.ini_options].","commonSituations":"Botched merge of pyproject.toml; copy-pasting a snippet that uses ' =' assignments invalid in TOML; trailing inline-table commas; non-ASCII paths without quotes.","solutions":["Open the file at {path} and locate the line/column from the TOMLDecodeError detail, then fix the TOML syntax.","Validate the file with an external TOML linter or 'python -c \"import tomllib; tomllib.loads(open(\\\"pyproject.toml\\\").read())\"'.","If a recent merge left conflict markers (<<<, >>>), resolve them and re-save."],"exampleFix":"// before\n[tool.pytest.ini_options]\naddopts = -ra\n  -q   # invalid: continuation needs array form\n// after\n[tool.pytest.ini_options]\naddopts = [\"-ra\", \"-q\"]","handlingStrategy":"validation","validationCode":"import tomllib, pathlib\n\ndef validate_toml(path: str) -> None:\n    try:\n        tomllib.loads(pathlib.Path(path).read_text(encoding='utf-8'))\n    except tomllib.TOMLDecodeError as e:\n        raise SystemExit(f'{path}: {e}') from e","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Lint pyproject.toml in CI with a TOML validator before running tests.","Resolve git merge conflicts in pyproject.toml before invoking pytest.","Use an editor with TOML syntax checking."],"tags":["config","toml","pyproject","parse-error"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}