{"id":"4f3bf2b479f55d5a","repo":"pytest-dev/pytest","slug":"unknown-parametrize-long-str-id-strategy-value-r","errorCode":null,"errorMessage":"Unknown parametrize_long_str_id_strategy: {value!r}. Valid values: {', '.join(sorted(_LONG_STR_STRATEGIES))}","messagePattern":"Unknown parametrize_long_str_id_strategy: (.+?)\\. Valid values: (.+?)","errorType":"exception","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/python.py","lineNumber":1041,"sourceCode":"        idval = self._idval_from_hook(val, argname)\n        if idval is not None:\n            return idval\n        if isinstance(val, str | bytes):\n            idval = self._apply_long_str_strategy(val, argname, idx)\n            if idval is not None:\n                return idval\n        else:\n            idval = self._idval_from_value(val)\n            if idval is not None:\n                return idval\n        return self._idval_from_argname(argname, idx)\n\n    def _get_long_str_strategy(self) -> LongStrIdStrategy:\n        if not self.config:\n            return \"short\"\n        value = self.config.getini(\"parametrize_long_str_id_strategy\")\n        if value not in _LONG_STR_STRATEGIES:\n            raise UsageError(\n                f\"Unknown parametrize_long_str_id_strategy: {value!r}. \"\n                f\"Valid values: {', '.join(sorted(_LONG_STR_STRATEGIES))}\"\n            )\n        return cast(LongStrIdStrategy, value)\n\n    def _apply_long_str_strategy(\n        self, val: str | bytes, argname: str, idx: int\n    ) -> str | None:\n        \"\"\"Apply the configured strategy for long str/bytes parameter values.\n\n        Only used for auto-generated IDs (not explicit ids=[...] or\n        pytest.param(id=...)).\n        \"\"\"\n        if len(val) <= 100:\n            return _ascii_escaped_by_config(val, self.config)\n        match self._get_long_str_strategy():\n            case \"legacy\":\n                return _ascii_escaped_by_config(val, self.config)","sourceCodeStart":1023,"sourceCodeEnd":1059,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/python.py#L1023-L1059","documentation":"Raised as UsageError by IdMaker._get_long_str_strategy when the ini option 'parametrize_long_str_id_strategy' has a value not in the allowed set {'short','sha256','legacy','disallow'}. This option controls how pytest generates test IDs for parametrized values that are long strings/bytes (>100 chars). An invalid value means config parsing accepted it but it is semantically unknown.","triggerScenarios":"Setting parametrize_long_str_id_strategy to a typo or unsupported string (e.g. 'none', 'hash', 'truncate') in pyproject.toml [tool.pytest.ini_options], pytest.ini, or tox.ini, then running any parametrized test.","commonSituations":"Misspelling the strategy name; carrying over a config from a plugin that defined custom strategies; using a value from an outdated docs page.","solutions":["Set the option to one of: 'short', 'sha256', 'legacy', or 'disallow'.","Remove the option to fall back to the default ('short').","Check the installed pytest version's docs for the current valid values."],"exampleFix":"// before (pyproject.toml)\n[tool.pytest.ini_options]\nparametrize_long_str_id_strategy = \"hash\"\n// after\n[tool.pytest.ini_options]\nparametrize_long_str_id_strategy = \"sha256\"","handlingStrategy":"validation","validationCode":"VALID = {\"short\", \"sha256\", \"legacy\", \"disallow\"}\nval = config.getini(\"parametrize_long_str_id_strategy\")\nif val is not None and val not in VALID:\n    raise SystemExit(f\"parametrize_long_str_id_strategy must be one of {sorted(VALID)}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only documented strategy names.","Remove the option to rely on the default.","Re-check valid values after upgrading pytest."],"tags":["configuration","parametrize","validation"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}