{
  "id": "elasticsearch/script-compilation-error",
  "signature": "ScriptException: compile error in Painless script [my_script] - unexpected token '[' at line 5",
  "signature_zh": "ScriptException: Painless 脚本 [my_script] 编译错误 - 在第5行发现意外标记 '['",
  "regex": ".*ScriptException.*compile error in Painless script.*unexpected token.*",
  "domain": "elasticsearch",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "The Painless script contains a syntax error, such as a missing bracket, invalid operator, or incorrect array access, causing compilation failure at runtime.",
  "root_cause_type": "generic",
  "root_cause_zh": "Painless 脚本包含语法错误，如缺少括号、无效运算符或数组访问错误，导致运行时编译失败。",
  "versions": [
    {
      "version": "7.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "7.17.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is a syntax token issue, not precedence. Adding parentheses may mask the real problem or introduce new errors.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This reduces performance significantly and does not fix the syntax error in the script itself.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Upgrading does not fix the script's syntax; it only changes how the error is reported. The root cause remains.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Debug the script using the Painless execute API: POST _scripts/painless/_execute { \"script\": { \"source\": \"return doc['field'].value;\", \"lang\": \"painless\" } } to isolate the syntax issue.",
      "success_rate": 0.9,
      "how": "Debug the script using the Painless execute API: POST _scripts/painless/_execute { \"script\": { \"source\": \"return doc['field'].value;\", \"lang\": \"painless\" } } to isolate the syntax issue.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Rewrite the script to avoid complex array access by using helper methods, e.g., replace `list[0]` with `list.get(0)`.",
      "success_rate": 0.85,
      "how": "Rewrite the script to avoid complex array access by using helper methods, e.g., replace `list[0]` with `list.get(0)`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Enable script compilation logging to see full error details: PUT _cluster/settings { \"transient\": { \"logger.org.elasticsearch.script\": \"DEBUG\" } }",
      "success_rate": 0.75,
      "how": "Enable script compilation logging to see full error details: PUT _cluster/settings { \"transient\": { \"logger.org.elasticsearch.script\": \"DEBUG\" } }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Debug the script using the Painless execute API: POST _scripts/painless/_execute { \"script\": { \"source\": \"return doc['field'].value;\", \"lang\": \"painless\" } } to isolate the syntax issue.",
    "Rewrite the script to avoid complex array access by using helper methods, e.g., replace `list[0]` with `list.get(0)`.",
    "Enable script compilation logging to see full error details: PUT _cluster/settings { \"transient\": { \"logger.org.elasticsearch.script\": \"DEBUG\" } }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-painless.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.86,
  "resolvable": "true",
  "first_seen": "2023-06-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}