{
  "id": "api/http-400-invalid-query-parameter-type",
  "signature": "400 Bad Request: invalid query parameter type — expected integer but got string",
  "signature_zh": "400 错误请求：查询参数类型无效 — 期望整数但得到字符串",
  "regex": "400\\s*(?:Bad Request)?[\\s\\S]*invalid\\s*(?:query\\s*)?parameter\\s*type[\\s\\S]*expected\\s*(?:integer|number|boolean)",
  "domain": "api",
  "category": "request_error",
  "subcategory": null,
  "root_cause": "The client provided a query parameter with an incorrect data type (e.g., a string where an integer is required), often due to missing type coercion or incorrect serialization.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端提供了数据类型不正确的查询参数（例如，需要整数却提供了字符串），通常是由于缺少类型强制转换或序列化错误。",
  "versions": [
    {
      "version": "OpenAPI 3.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Django REST Framework 3.14+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "FastAPI 0.100+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "URL query parameters are strings by default; the server expects an unquoted integer, so quoting only adds extra characters and still fails.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This alters the API contract and may break other clients or validation logic; it's a workaround that hides the real issue.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The parameter is present but with wrong type; adding a default doesn't fix the type mismatch.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the client sends the parameter as a raw integer in the URL (e.g., `?id=123` not `?id=\"123\"`). In JavaScript, use `encodeURIComponent` but avoid quoting numbers. Example: `fetch('/api/resource?id=' + 123)`.",
      "success_rate": 0.95,
      "how": "Ensure the client sends the parameter as a raw integer in the URL (e.g., `?id=123` not `?id=\"123\"`). In JavaScript, use `encodeURIComponent` but avoid quoting numbers. Example: `fetch('/api/resource?id=' + 123)`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Update the API schema to accept string parameters and perform server-side type coercion (e.g., using `int()` in Python with error handling). Example FastAPI: `@app.get(\"/items/{item_id}\")` with `item_id: int`.",
      "success_rate": 0.85,
      "how": "Update the API schema to accept string parameters and perform server-side type coercion (e.g., using `int()` in Python with error handling). Example FastAPI: `@app.get(\"/items/{item_id}\")` with `item_id: int`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Log the raw query string on the server to debug the exact value sent. Example: `print(request.query_params)` in Django, then compare with expected format.",
      "success_rate": 0.9,
      "how": "Log the raw query string on the server to debug the exact value sent. Example: `print(request.query_params)` in Django, then compare with expected format.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保客户端在 URL 中以原始整数形式发送参数（例如 `?id=123` 而不是 `?id=\"123\"`）。在 JavaScript 中，使用 `encodeURIComponent` 但避免对数字加引号。示例：`fetch('/api/resource?id=' + 123)`。",
    "更新 API 架构以接受字符串参数并在服务器端执行类型强制转换（例如，在 Python 中使用带有错误处理的 `int()`）。FastAPI 示例：`@app.get(\"/items/{item_id}\")` 使用 `item_id: int`。",
    "在服务器端记录原始查询字符串以调试确切发送的值。示例：在 Django 中 `print(request.query_params)`，然后与预期格式比较。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://swagger.io/docs/specification/describing-parameters/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-08-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}