{"record":{"id":"ca40c225402b7e62","repo":"kestra-io/kestra","slug":"unable-to-deserialize-value-as-it-s-neither-an-obj","errorCode":null,"errorMessage":"Unable to deserialize value as it's neither an object neither an array","messagePattern":"Unable to deserialize value as it's neither an object neither an array","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/serializers/ListOrMapOfLabelDeserializer.java","lineNumber":46,"sourceCode":"            List<Map<String, String>> ret = ctxt.readValue(p, List.class);\n            return ret.stream().map(map ->\n            {\n                Object value = map.get(\"value\");\n                if (isAllowedType(value)) {\n                    return new Label(map.get(\"key\"), String.valueOf(value));\n                } else {\n                    throw new IllegalArgumentException(\"Unsupported type for key: \" + map.get(\"key\") + \", value: \" + value);\n                }\n            }).toList();\n        } else if (p.hasToken(JsonToken.START_OBJECT)) {\n            // deserialize as map\n            Map<String, Object> ret = ctxt.readValue(p, Map.class);\n            return ret == null ? null\n                : ret.entrySet().stream()\n                    .map(this::validateAndCreateLabel)\n                    .toList();\n        }\n        throw new IllegalArgumentException(\"Unable to deserialize value as it's neither an object neither an array\");\n    }\n\n    private Label validateAndCreateLabel(Map.Entry<String, Object> entry) {\n        Object value = entry.getValue();\n        if (isAllowedType(value)) {\n            return new Label(entry.getKey(), String.valueOf(value));\n        } else {\n            throw new IllegalArgumentException(\"Unsupported type for key: \" + entry.getKey() + \", value: \" + value);\n        }\n    }\n\n    private static boolean isAllowedType(Object value) {\n        return value instanceof String ||\n            value instanceof Integer ||\n            value instanceof Long ||\n            value instanceof Float ||\n            value instanceof Double ||\n            value instanceof Boolean;","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/serializers/ListOrMapOfLabelDeserializer.java#L28-L64","documentation":"The `ListOrMapOfLabelDeserializer` only handles three JSON token types: `VALUE_NULL`, `START_ARRAY`, and `START_OBJECT`. If the labels field is any other token type (e.g., a bare string, number, or boolean scalar), it falls through all branches and throws `IllegalArgumentException`. This means the labels field was provided as a raw scalar value rather than a structured array or object.","triggerScenarios":"Submitting `\"labels\": \"some_string\"` or `\"labels\": 42` in a flow/execution JSON payload. The labels field must be a JSON array or object, not a scalar.","commonSituations":"An API consumer mistakenly passes a single string instead of a list or map of labels. A malformed JSON payload where the labels field is a bare value due to a serialization bug.","solutions":["Provide labels as either a JSON array of `{key, value}` objects or a JSON map of `{key: value}` pairs.","If no labels are needed, omit the field entirely or set it to null, not an empty string."],"exampleFix":"# before\nlabels: \"my-label\"\n# after\nlabels:\n  - key: my-label\n    value: \"true\"","handlingStrategy":"validation","validationCode":"// Validate that labels is an array or object before deserialization\nimport com.fasterxml.jackson.databind.JsonNode;\n\npublic static void validateLabelsShape(JsonNode labelsNode) {\n    if (labelsNode == null || labelsNode.isNull()) return;\n    if (!labelsNode.isArray() && !labelsNode.isObject()) {\n        throw new IllegalArgumentException(\n            \"labels must be a JSON array or object, got: \" + labelsNode.getNodeType());\n    }\n}","typeGuard":"function isLabelContainer(v: unknown): boolean {\n    return Array.isArray(v) || (typeof v === 'object' && v !== null);\n}","tryCatchPattern":null,"preventionTips":["Always provide labels as a JSON array of objects or a JSON map, never a bare scalar.","Use the correct API payload schema from the OpenAPI docs.","Validate payload structure with a JSON schema validator before submission."],"tags":["labels","deserializer","jackson","format-error","validation"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}