{
  "id": "python/pytest-parametrize-id-error",
  "signature": "TypeError: ids must be a list of strings or None, got int",
  "signature_zh": "类型错误：ids 必须是字符串列表或 None，但收到了 int",
  "regex": "TypeError:\\ ids\\ must\\ be\\ a\\ list\\ of\\ strings\\ or\\ None,\\ got\\ int",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "The 'ids' parameter in @pytest.mark.parametrize is provided as a non-string iterable (e.g., list of integers) instead of strings.",
  "root_cause_type": "generic",
  "root_cause_zh": "@pytest.mark.parametrize 中的 'ids' 参数被提供为非字符串可迭代对象（例如整数列表），而不是字符串。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using list comprehension to convert ids to strings but forgetting to pass them",
      "why_fails": "If the conversion is not applied to the ids parameter, the error persists.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Omitting the ids parameter entirely",
      "why_fails": "Tests will run without custom IDs, but the error is avoided; however, test reports may be less readable.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Convert ids to a list of strings using str() or a lambda.",
      "success_rate": 0.95,
      "how": "@pytest.mark.parametrize('arg', [1, 2], ids=[str(x) for x in [1, 2]])",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a lambda function to generate ids dynamically.",
      "success_rate": 0.9,
      "how": "@pytest.mark.parametrize('arg', [1, 2], ids=lambda x: f'case_{x}')",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}