{"record":{"id":"1863ce3662aab4d9","repo":"kestra-io/kestra","slug":"unable-to-parse-array-element-as-on","errorCode":null,"errorMessage":"Unable to parse array element as `{}` on `{}`","messagePattern":"Unable to parse array element as `(.+?)` on `(.+?)`","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/FlowInputOutput.java","lineNumber":595,"sourceCode":"                    yield current.toString();\n                }\n                case ARRAY, MULTISELECT -> {\n                    List<?> asList;\n                    if (current instanceof List<?> list) {\n                        asList = list;\n                    } else {\n                        asList = JacksonMapper.toList(((String) current));\n                    }\n\n                    if (elementType != null) {\n                        // recursively parse the elements only once\n                        yield asList.stream()\n                            .map(throwFunction(element ->\n                            {\n                                try {\n                                    return parseType(execution, elementType, id, null, element, data);\n                                } catch (Throwable e) {\n                                    throw new IllegalArgumentException(\"Unable to parse array element as `\" + elementType + \"` on `\" + element + \"`\", e);\n                                }\n                            }))\n                            .toList();\n                    } else {\n                        yield asList;\n                    }\n                }\n                case FORM, REUSABLE_INPUTS -> throw new IllegalStateException(\"FORM and REUSABLE_INPUTS inputs must be expanded before resolution\");\n            };\n        } catch (IllegalArgumentException | ConstraintViolationException e) {\n            throw e;\n        } catch (Throwable e) {\n            throw new Exception(\" errors:\\n```\\n\" + e.getMessage() + \"\\n```\");\n        }\n    }\n\n    private static Execution minimalExecution(FlowInterface flow, String executionId) {\n        return Execution.builder()","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/FlowInputOutput.java#L577-L613","documentation":"Thrown while recursively parsing each element of an ARRAY or MULTISELECT input/output against its declared `itemType`. When a single element cannot be coerced to that element type (e.g. a STRING declared INT, or a malformed JSON object for a RECORD), `parseType` fails and the failure is re-wrapped naming both the expected element type and the offending element value. The two placeholders are the declared `elementType` and the raw `element` that failed to parse.","triggerScenarios":"An input of type ARRAY with an `itemType` (e.g. `itemType: INT`) is submitted where at least one list entry is not coercible — e.g. values `[1, \"abc\", 3]` for an INT array, or a JSON object where a STRING was expected. Also triggered by a MULTISELECT whose rendered value yields mixed-type entries, or by a RECORD/JSON itemType whose element is not valid JSON for that schema.","commonSituations":"Submitting flow inputs via the API or UI with mismatched element types; a Pebble-rendered array expression that injects a non-numeric token into a numeric array; downstream tasks passing outputs of the wrong shape into a subflow input declared as a typed array; CSV/JSON source data containing a null or string where a number was expected.","solutions":["Inspect the error's element value and elementType: align the submitted array entry with the declared itemType (convert the string to a number, fix the JSON object shape, etc.).","If the source data is heterogeneous, change the input's `itemType` to a more permissive type (e.g. STRING or JSON) or pre-clean the data before submission.","Validate the rendered array with a Pebble expression or a pre-task before it reaches the typed input.","When the element is legitimately optional, mark the input `required: false` and handle nulls inside the flow."],"exampleFix":"# before (flow input)\nid: my_flow\ninputs:\n  - id: numbers\n    type: ARRAY\n    itemType: INT\n# submission: {\"numbers\": [1, \"two\", 3]}\n\n# after — coerce source data to integers before submit\n#   or relax the itemType\ninputs:\n  - id: numbers\n    type: ARRAY\n    itemType: STRING","handlingStrategy":"validation","validationCode":"// Before submitting, verify every array entry matches itemType\nObject rendered = renderInput(valuesExpression);\nif (rendered instanceof List<?> list) {\n    for (Object e : list) {\n        if (!isAssignable(elementType, e)) {\n            throw new IllegalArgumentException(\n                \"Array entry \" + e + \" is not compatible with itemType \" + elementType);\n        }\n    }\n}","typeGuard":"static boolean isAssignable(io.kestra.core.models.tasks.runners.Type itemType, Object element) {\n    return switch (itemType) {\n        case INT    -> element instanceof Integer || element instanceof Long || (element instanceof String s && s.matches(\"-?\\\\d+\"));\n        case FLOAT  -> element instanceof Number;\n        case BOOL   -> element instanceof Boolean;\n        case STRING -> element instanceof CharSequence;\n        default     -> true; // JSON/RECORD: accept and let Jackson validate\n    };\n}","tryCatchPattern":"try {\n    outputs = flowInputOutput.parseExecutionInputs(flow, execution, inputs);\n} catch (IllegalArgumentException e) {\n    // message already names elementType + offending element\n    return badRequest(e.getMessage());\n}","preventionTips":["Declare the most permissive itemType that still matches your data, or pre-clean the source.","Unit-test input parsing with representative (including malformed) fixtures.","When iterating over external data, coerce/normalize entries with a Pebble map before the typed input."],"tags":["inputs","type-conversion","array","validation"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}