{"record":{"id":"791f860ebb15d8d0","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-uuids","errorCode":null,"errorMessage":"Converter can only convert UUIDs","messagePattern":"Converter can only convert UUIDs","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/UUIDRestVariableConverter.java","lineNumber":47,"sourceCode":"        return UUID.class;\n    }\n\n    @Override\n    public Object getVariableValue(EngineRestVariable result) {\n        if (result.getValue() != null) {\n            if (!(result.getValue() instanceof String)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert Strings\");\n            }\n            return UUID.fromString((String) result.getValue());\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof UUID)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert UUIDs\");\n            }\n            result.setValue(((UUID)variableValue).toString());\n        } else {\n            result.setValue(null);\n        }\n    }\n\n}\n","sourceCodeStart":29,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/UUIDRestVariableConverter.java#L29-L56","documentation":"UUIDRestVariableConverter.convertVariableValue serializes a java.util.UUID variable to its REST String form. It strictly requires an instanceof UUID input; other types (including Strings) are rejected with FlowableIllegalArgumentException.","triggerScenarios":"Calling convertVariableValue(value, result) with a String, Long, or other non-UUID object when the variable is declared the UUID REST type.","commonSituations":"Variables read from storage as strings then passed back to the UUID converter; type confusion between the two directions of this converter; custom response assembly code.","solutions":["Ensure the value is a java.util.UUID instance; parse strings via UUID.fromString first.","Use StringRestVariableConverter if the variable is actually stored as a string.","Check the variable type at creation time so UUID-typed variables remain UUID objects."],"exampleFix":"// before\nconverter.convertVariableValue(\"550e8400-e29b-41d4-a716-446655440000\", result); // throws\n// after\nconverter.convertVariableValue(UUID.fromString(\"550e8400-e29b-41d4-a716-446655440000\"), result);","handlingStrategy":"type-guard","validationCode":"if (variableValue != null && !(variableValue instanceof UUID)) {\n    variableValue = UUID.fromString(variableValue.toString());\n}","typeGuard":"static UUID asUuid(Object v) {\n    if (v instanceof UUID) return (UUID) v;\n    if (v instanceof String) return UUID.fromString((String) v);\n    return null;\n}","tryCatchPattern":"try {\n    converter.convertVariableValue(value, result);\n} catch (FlowableIllegalArgumentException e) {\n    result.setValue(asUuid(value).toString());\n}","preventionTips":["Ensure UUID variables remain UUID instances end-to-end.","Parse strings to UUID before handing values to this converter.","Note the asymmetry: get-direction expects String, convert-direction expects UUID."],"tags":["type-mismatch","uuid","rest-variable"],"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"}