{
  "id": "kubernetes/ingress-rewrite-target-missing",
  "signature": "Error: rewrite-target annotation value must be a valid regex",
  "signature_zh": "错误：rewrite-target 注解值必须是有效的正则表达式",
  "regex": "rewrite-target annotation value must be a valid regex",
  "domain": "kubernetes",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The nginx.ingress.kubernetes.io/rewrite-target annotation is set to an invalid regex pattern or empty string, causing the ingress controller to reject the configuration.",
  "root_cause_type": "generic",
  "root_cause_zh": "nginx.ingress.kubernetes.io/rewrite-target 注解被设置为无效的正则表达式模式或空字符串，导致 Ingress 控制器拒绝该配置。",
  "versions": [
    {
      "version": "nginx-ingress-controller 1.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx-ingress-controller 1.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ingress-nginx 4.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Setting rewrite-target to '/' with no capture groups",
      "why_fails": "路径不匹配时重写为根路径会导致 404，且不解决正则无效问题",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Removing the rewrite-target annotation entirely",
      "why_fails": "后端服务可能依赖路径重写，移除会导致路由错误",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a wildcard '*' in the regex pattern",
      "why_fails": "星号不是有效正则，反而会触发相同错误",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a valid regex with capture groups: 'nginx.ingress.kubernetes.io/rewrite-target: /$2' and path: '/api(/|$)(.*)'",
      "success_rate": 0.9,
      "how": "Use a valid regex with capture groups: 'nginx.ingress.kubernetes.io/rewrite-target: /$2' and path: '/api(/|$)(.*)'",
      "condition": "",
      "sources": []
    },
    {
      "action": "Validate regex with online tool before applying, then check with: kubectl describe ingress <ingress-name>",
      "success_rate": 0.85,
      "how": "Validate regex with online tool before applying, then check with: kubectl describe ingress <ingress-name>",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use a valid regex with capture groups: 'nginx.ingress.kubernetes.io/rewrite-target: /$2' and path: '/api(/|$)(.*)'",
    "Validate regex with online tool before applying, then check with: kubectl describe ingress <ingress-name>"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#rewrite",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-08-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}