pytest-dev/pytest · error · ValueError
unknown configuration type
Error message
unknown configuration type: {type} What it means
Config__getini_unknown_type (legacypath.py:395) handles ini option retrieval for the legacy 'pathlist' type and raises ValueError('unknown configuration type: {type}', value) for any other unrecognized type. This path is reached when a plugin registers an ini option with a 'type' string that the core config does not know how to coerce (only 'pathlist' is handled here as a legacy shim).
Solutions
- Use a standard type string in addini (e.g. 'string', 'bool', 'int', 'pathlist', 'args', 'linelist', 'paths').
- If a custom type is required, post-process the raw string value yourself instead of declaring a custom type.
- Verify the ini option's registered type against the list supported by your pytest version.
Example fix
// before
parser.addini('targets', type='csvlist', default=[])
value = config.getini('targets')
// after
parser.addini('targets', type='linelist', default=[])
value = [x.split(',') for x in config.getini('targets'))] Defensive patterns
Strategy: validation
Validate before calling
ALLOWED = {'string','bool','int','float','pathlist','paths','args','linelist','choice'}
def addini_checked(parser, name, type, help, **kw):
assert type in ALLOWED, f'unsupported ini type {type!r}; use one of {ALLOWED}'
parser.addini(name, type=type, help=help, **kw) Type guard
def is_known_ini_type(t: str) -> bool:
return t in {'string','bool','int','float','pathlist','paths','args','linelist','choice'} Prevention
- Use only standard ini type strings.
- Post-process raw string values for custom formats.
- Document each custom ini option's type.
When it happens
Trigger: A plugin/conftest calling parser.addini('opt', type='mytype') where 'mytype' is not one of the recognized type names, and then code calls config.getini('opt') triggering the legacy fallback; mixing the fspath/legacypath compatibility layer with a custom type.
Common situations: Custom ini types added without registering a corresponding getini handler; pytest version mismatch where a type previously handled by legacypath no longer is; plugin conflicts overriding getini behavior.
Related errors
- help argument cannot be None for
- ' ' is not recognized as a logging level name for ' '…
- unknown configuration value
- alias conflicts with existing configuration option
- is already an alias of
AI-assisted analysis of pytest-dev/pytest@0d6fbdeffa (2026-08-11).
Data as JSON: /api/errors/858d32903583257a.
Report an issue: GitHub.
Appendix: 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 0d6fbdeffa)