{"record":{"id":"a2d3c4476353c385","repo":"flowable/flowable-engine","slug":"cannot-coerce-property-to-array-index-a2d3c4","errorCode":null,"errorMessage":"Cannot coerce property to array index: ","messagePattern":"Cannot coerce property to array index: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/javax/el/ArrayELResolver.java","lineNumber":328,"sourceCode":"\tprivate static int coerce(Object property) {\n\t\tif (property instanceof Number) {\n\t\t\treturn ((Number) property).intValue();\n\t\t}\n\t\tif (property instanceof Character) {\n\t\t\treturn (Character) property;\n\t\t}\n\t\tif (property instanceof Boolean) {\n\t\t\treturn (Boolean) property ? 1 : 0;\n\t\t}\n\t\tif (property instanceof String) {\n\t\t\ttry {\n\t\t\t\treturn Integer.parseInt((String) property);\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new IllegalArgumentException(\"Cannot parse array index: \" + property, e);\n\t\t\t}\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\"Cannot coerce property to array index: \" + property);\n\t}\n}\n","sourceCodeStart":310,"sourceCodeEnd":331,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/javax/el/ArrayELResolver.java#L310-L331","documentation":"ArrayELResolver.coerce throws IllegalArgumentException when the EL property used as an array index is neither a Number, Boolean, nor parseable String — e.g. an arbitrary object — and cannot be coerced to an int index.","triggerScenarios":"Evaluating ${myArray[someObject]} or ${myArray[true && x]} where the property resolves to a non-coercible type such as a POJO, List, or Date.","commonSituations":"Using map/object property syntax against arrays; an index expression accidentally returning a complex object instead of a number.","solutions":["Make the index expression evaluate to a Number or numeric String.","Replace the array with a Map if you intend non-integer keyed access.","Inspect the index sub-expression's return type and fix the type mismatch."],"exampleFix":"// before\nengine.eval(\"${rows[date]}\" )\n// after\nengine.eval(\"${rows[rowIndex]}\") // rowIndex is an Integer in the EL context","handlingStrategy":"type-guard","validationCode":"if (!(indexProp instanceof Number) && !(indexProp instanceof String) && !(indexProp instanceof Boolean)) throw new IllegalArgumentException(\"index not coercible: \" + indexProp);","typeGuard":"boolean isCoercibleIndex(Object p) { return p instanceof Number || p instanceof Boolean || (p instanceof String s && s.matches(\"-?\\\\d+\")); }","tryCatchPattern":"try { resolver.getValue(ctx, base, prop); } catch (IllegalArgumentException e) { /* fix index expression type */ }","preventionTips":["Ensure index sub-expressions evaluate to Number/String/Boolean","Avoid complex objects as array indexes","Add unit tests for dynamic index expressions"],"tags":["el","array","type-mismatch","expression-language"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}