{
  "id": "nginx/upstream-sent-invalid-content-length",
  "signature": "upstream sent invalid content-length while reading response header from upstream",
  "signature_zh": "上游发送了无效的 Content-Length 头",
  "regex": "upstream sent invalid content-length while reading response header from upstream",
  "domain": "nginx",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "Upstream server returned a Content-Length header with a negative or non-numeric value, violating HTTP protocol.",
  "root_cause_type": "generic",
  "root_cause_zh": "上游服务器返回了包含负数或非数字值的 Content-Length 头，违反了 HTTP 协议。",
  "versions": [
    {
      "version": "nginx/1.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx/1.22.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx/1.26.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Buffer size does not affect header validity; the error is about malformed header value, not size.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Even without buffering, nginx parses response headers; the invalid Content-Length is still detected.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This controls request body size, not response header validation.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Fix the upstream application to return a valid Content-Length header (e.g., in Python Flask: remove or set correct Content-Length via response.headers['Content-Length'] = str(len(data)))",
      "success_rate": 0.95,
      "how": "Fix the upstream application to return a valid Content-Length header (e.g., in Python Flask: remove or set correct Content-Length via response.headers['Content-Length'] = str(len(data)))",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add proxy_ignore_headers Content-Length; in nginx config to ignore upstream's Content-Length if it is invalid (use with caution). Example: location / { proxy_pass http://backend; proxy_ignore_headers Content-Length; }",
      "success_rate": 0.8,
      "how": "Add proxy_ignore_headers Content-Length; in nginx config to ignore upstream's Content-Length if it is invalid (use with caution). Example: location / { proxy_pass http://backend; proxy_ignore_headers Content-Length; }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Update upstream server code to not send Content-Length for chunked responses (e.g., in Node.js: res.removeHeader('Content-Length') before piping).",
      "success_rate": 0.85,
      "how": "Update upstream server code to not send Content-Length for chunked responses (e.g., in Node.js: res.removeHeader('Content-Length') before piping).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Fix the upstream application to return a valid Content-Length header (e.g., in Python Flask: remove or set correct Content-Length via response.headers['Content-Length'] = str(len(data)))",
    "Add proxy_ignore_headers Content-Length; in nginx config to ignore upstream's Content-Length if it is invalid (use with caution). Example: location / { proxy_pass http://backend; proxy_ignore_headers Content-Length; }",
    "Update upstream server code to not send Content-Length for chunked responses (e.g., in Node.js: res.removeHeader('Content-Length') before piping)."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nginx.org/en/docs/http/ngx_http_upstream_module.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}