{
  "id": "python/pytest-mark-parametrize-ids-mismatch",
  "signature": "ValueError: Incorrect number of ids: 3 instead of 2",
  "signature_zh": "ValueError: id 数量不正确：3 而不是 2",
  "regex": "ValueError:\\ Incorrect\\ number\\ of\\ ids:\\ 3\\ instead\\ of\\ 2",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "In @pytest.mark.parametrize, the `ids` list length must match the number of parameter sets (not the number of arguments). Supplying too many or too few ids raises ValueError.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 @pytest.mark.parametrize 中，`ids` 列表长度必须与参数集的数量匹配（而不是参数个数）。提供过多或过少的 id 会引发 ValueError。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "pytest expects an iterable of id strings (or a callable); a single string is treated as an iterable of characters, producing confusing ids and possibly a length mismatch.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Works but loses readable test names; not a real fix if the user needs custom ids for reporting.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "@pytest.mark.parametrize(\n    'a,b',\n    [(1, 2), (3, 4)],\n    ids=['small', 'large'],  # 2 ids for 2 tuples\n)\ndef test_add(a, b):\n    ...",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "def idfn(val):\n    return f'v={val}'\n\n@pytest.mark.parametrize('x', [1, 2, 3], ids=idfn)\ndef test_x(x):\n    ...",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}