pytest-dev/pytest · error · ValueError
unknown configuration type: {type}
Error message
unknown configuration type: {type} What it means
Raised by the legacy-path compatibility shim `Config__getini_unknown_type` when `config.getini(name)` encounters an ini option whose registered type is neither a standard pytest type nor the legacy "pathlist". The shim only knows how to convert "pathlist"; any other unknown type string bubbles up as ValueError carrying the type and value.
Source
Thrown at src/_pytest/legacypath.py:395
def Session_startdir(self: Session) -> LEGACY_PATH:
"""The path from which pytest was invoked.
Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
:type: LEGACY_PATH
"""
return legacy_path(self.startpath)
def Config__getini_unknown_type(self, name: str, type: str, value: str | list[str]):
if type == "pathlist":
# TODO: This assert is probably not valid in all cases.
assert self.inipath is not None
dp = self.inipath.parent
input_values = shlex.split(value) if isinstance(value, str) else value
return [legacy_path(str(dp / x)) for x in input_values]
else:
raise ValueError(f"unknown configuration type: {type}", value)
def Node_fspath(self: Node) -> LEGACY_PATH:
"""(deprecated) returns a legacy_path copy of self.path"""
return legacy_path(self.path)
def Node_fspath_set(self: Node, value: LEGACY_PATH) -> None:
self.path = Path(value)
@hookimpl(tryfirst=True)
def pytest_load_initial_conftests(early_config: Config) -> None:
"""Monkeypatch legacy path attributes in several classes, as early as possible."""
mp = MonkeyPatch()
early_config.add_cleanup(mp.undo)
# Add Cache.makedir().View on GitHub (pinned to 98b357f69e)
Solutions
- Use one of the standard ini types ("string", "paths", "pathlist", "args", "linelist", "bool") in `addini`.
- If a custom type is needed, handle parsing yourself and register the option as a plain string.
- Update/check the plugin that registered the option for a typo or incompatible type name.
Example fix
// before
parser.addini("my_opt", type="json", default="{}") # unknown type
// after
parser.addini("my_opt", type="string", default="{}")
# then parse JSON yourself when reading Defensive patterns
Strategy: validation
Validate before calling
VALID_INI_TYPES = {"string", "paths", "pathlist", "args", "linelist", "bool"}
def safe_addini(parser, name, type=None, **kw):
if type is not None and type not in VALID_INI_TYPES:
raise ValueError(f"unknown configuration type: {type}")
parser.addini(name, type=type, **kw) Type guard
def is_known_ini_type(type_name: str) -> bool:
return type_name in {"string", "paths", "pathlist", "args", "linelist", "bool"} Prevention
- Use only standard ini types when registering options.
- Parse custom formats yourself from a string-typed option.
- Check for typos in the type argument.
When it happens
Trigger: A plugin registers an ini option with a non-standard `type=` value (e.g. `type="json"`) and the value is later read through the legacy path layer, or `legacypath` is the only handler available for that type. The error reports the offending type string.
Common situations: Custom plugin defining a bespoke ini type. Version mismatch between a plugin and pytest where a type name changed. Mis-typed `addini(..., type="sting")` typo.
Related errors
- unknown configuration value: {name!r}
- {self.inipath}: config option '{name}' expects one of {_ini_
- {self.inipath}: config option '{name}' expects a string, got
- {self.inipath}: config option '{name}' expects one of {_ini_
- Expected an int string for option {name} of type integer, bu
AI-assisted analysis of pytest-dev/pytest@98b357f69e (2026-08-04).
Data as JSON: /data/errors/858d32903583257a.json.
Report an issue: GitHub.