{"record":{"id":"9f6a165435bc725a","repo":"kestra-io/kestra","slug":"unsupported-type-for-key-key-value-value","errorCode":null,"errorMessage":"Unsupported type for key: {key}, value: {value}","messagePattern":"Unsupported type for key: (.+?), value: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/serializers/ListOrMapOfLabelDeserializer.java","lineNumber":35,"sourceCode":" * This deserializer is for historical purpose, labels was first a map but has been updated to a List of Label so\n * this deserializer allows using both types.\n */\npublic class ListOrMapOfLabelDeserializer extends JsonDeserializer<List<Label>> implements ResolvableDeserializer {\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public List<Label> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {\n        if (p.hasToken(JsonToken.VALUE_NULL)) {\n            return null;\n        } else if (p.hasToken(JsonToken.START_ARRAY)) {\n            // deserialize as list\n            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 {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/serializers/ListOrMapOfLabelDeserializer.java#L17-L53","documentation":"The `ListOrMapOfLabelDeserializer` parses a `labels` field that can be either a JSON array of `{key, value}` objects or a JSON map. When parsing the array form, each label's `value` is type-checked via `isAllowedType()`. Only String, Integer, Long, Float, Double, and Boolean are accepted. If the value is a nested object, array, or null (in some cases), an `IllegalArgumentException` is thrown with the offending key and value.","triggerScenarios":"Submitting a flow or execution with a labels array where a value is a JSON object or array, e.g. `[{\"key\":\"meta\",\"value\":{\"nested\":true}}]`. Providing a null value in the array form.","commonSituations":"An API consumer sends a complex/nested value where a scalar is expected. A serialization issue causes a value to be sent as a map or list instead of a string.","solutions":["Ensure every label value in the array form is a scalar: String, number, or boolean.","If you need complex metadata, serialize it to a JSON string first.","Validate the labels payload against the expected schema before submission."],"exampleFix":"# before\nlabels:\n  - key: meta\n    value:\n      nested: true\n# after\nlabels:\n  - key: meta\n    value: '{\"nested\":true}'","handlingStrategy":"validation","validationCode":"// Validate label values before serialization\nimport io.kestra.core.models.Label;\n\npublic static List<Label> validateLabels(List<Label> labels) {\n    for (Label label : labels) {\n        Object value = label.value();\n        if (!(value instanceof String || value instanceof Integer || value instanceof Long\n            || value instanceof Float || value instanceof Double || value instanceof Boolean)) {\n            throw new IllegalArgumentException(\n                \"Label '\" + label.key() + \"' has unsupported value type: \" + value.getClass());\n        }\n    }\n    return labels;\n}","typeGuard":"function isAllowedLabelValue(v: unknown): boolean {\n    const t = typeof v;\n    return t === 'string' || t === 'number' || t === 'boolean';\n}","tryCatchPattern":null,"preventionTips":["Always use scalar values (string, number, boolean) for label values.","Serialize complex objects to JSON strings before using them as label values.","Validate the labels payload schema before submitting to the API."],"tags":["labels","deserializer","jackson","type-error","validation"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}