{"record":{"id":"4a65c7dd6734c979","repo":"flowable/flowable-engine","slug":"the-eventfield-must-resolve-to-an-number-or-a","errorCode":null,"errorMessage":"The [<eventField>] must resolve to an Number or a String that can be parsed as an Integer. Resolved to [<class>] for [<value>]","messagePattern":"The \\[<eventField>\\] must resolve to an Number or a String that can be parsed as an Integer\\. Resolved to \\[<class>\\] for \\[<value>\\]","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry-spring/src/main/java/org/flowable/eventregistry/spring/kafka/EventPayloadKafkaPartitionProvider.java","lineNumber":47,"sourceCode":"    @Override\n    public Integer determinePartition(OutboundEvent<?> outboundEvent) {\n        for (EventPayloadInstance payloadInstance : outboundEvent.getEventInstance()\n                .getPayloadInstances()) {\n            if (eventField.equals(payloadInstance.getDefinitionName())) {\n                return parseValue(payloadInstance.getValue());\n            }\n        }\n\n        return null;\n    }\n\n    protected Integer parseValue(Object value) {\n        if (value instanceof Number) {\n            return ((Number) value).intValue();\n        } else if (value instanceof String) {\n            return Integer.parseInt(value.toString());\n        } else if (value != null) {\n            throw new IllegalStateException(\n                    \"The [\" + eventField + \"] must resolve to an Number or a String that can be parsed as an Integer. \"\n                            + \"Resolved to [\" + value.getClass() + \"] for [\" + value + \"]\");\n        }\n\n        return null;\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry-spring/src/main/java/org/flowable/eventregistry/spring/kafka/EventPayloadKafkaPartitionProvider.java#L29-L55","documentation":"EventPayloadKafkaPartitionProvider.parseValue() computes a Kafka partition from an event payload field, which must be a Number or a numeric String. If the resolved value is non-null but of any other type, it throws an IllegalStateException describing the field, the actual class, and the value. Integer.parseInt failures on non-numeric strings throw NumberFormatException instead.","triggerScenarios":"determinePartition -> parseValue when the event payload field configured as partition key resolves to e.g. a Map, Boolean, or POJO instead of a Number/numeric String.","commonSituations":"Event payload schema sends the partition key as an object or boolean; eventField configuration points at the wrong payload path; producer sends JSON where the key is nested or typed unexpectedly.","solutions":["Fix the event payload so the configured eventField is a Number or numeric String.","Correct the eventField configuration to point at the right payload property containing the partition value.","Add producer-side validation/coercion converting the key to an integer before publishing.","Wrap determinePartition in a guard that validates the payload type and falls back to null partition (round-robin)."],"exampleFix":"// before: payload key is an object\npayload.put(\"partitionKey\", Map.of(\"id\", 42));\n\n// after: numeric value the provider can parse\npayload.put(\"partitionKey\", 42);","handlingStrategy":"type-guard","validationCode":"Object v = payload.get(eventField);\nif (v != null && !(v instanceof Number) && !(v instanceof String)) {\n    throw new IllegalArgumentException(eventField + \" must be Number or numeric String, got \" + v.getClass());\n}","typeGuard":"boolean isPartitionKeyValue(Object v) {\n    return v == null || v instanceof Number\n        || (v instanceof String s && s.matches(\"-?\\\\d+\"));\n}","tryCatchPattern":"try {\n    Integer partition = provider.determinePartition(event, channelModel);\n} catch (IllegalStateException | NumberFormatException e) {\n    log.warn(\"Bad partition key for field {}: {}\", eventField, e.getMessage());\n    // fall back to null partition (round-robin)\n}","preventionTips":["Validate partition key types at the producer before publishing.","Keep the eventField path pointing at a scalar numeric payload property.","Add schema validation for event payloads."],"tags":["kafka","partitioning","type-mismatch","event-payload"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}