{"record":{"id":"94360d1106547424","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-strings-94360d","errorCode":null,"errorMessage":"Converter can only convert Strings","messagePattern":"Converter can only convert Strings","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/UUIDRestVariableConverter.java","lineNumber":36,"sourceCode":"import org.flowable.common.engine.api.FlowableIllegalArgumentException;\n\npublic class UUIDRestVariableConverter implements RestVariableConverter {\n\n    @Override\n    public String getRestTypeName() {\n        return \"uuid\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        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","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/UUIDRestVariableConverter.java#L18-L54","documentation":"UUIDRestVariableConverter.getVariableValue turns the REST representation (a String) back into a java.util.UUID. It requires the stored value to be a String; any other type throws FlowableIllegalArgumentException with the message 'Converter can only convert Strings'.","triggerScenarios":"Calling getVariableValue on an EngineRestVariable whose value is not a String (e.g. a UUID object or number) while the UUID converter handles that variable type.","commonSituations":"Someone pre-converted the value to UUID before REST lookup; a variable of another type routed to the UUID converter; custom code building EngineRestVariable with UUID instead of its String form.","solutions":["Store the UUID as its String form (uuid.toString()) in EngineRestVariable before conversion.","Ensure the variable is genuinely the UUID REST type; otherwise route to the correct converter.","Also validate the string is a valid UUID format, since UUID.fromString would throw IllegalArgumentException next."],"exampleFix":"// before\nresult.setValue(UUID.randomUUID()); // UUID object, not String\n// after\nresult.setValue(UUID.randomUUID().toString());","handlingStrategy":"validation","validationCode":"if (result.getValue() != null) {\n    if (!(result.getValue() instanceof String)) throw new IllegalArgumentException(\"UUID variable value must be a String\");\n    UUID.fromString((String) result.getValue()); // also validates format\n}","typeGuard":"static boolean isUuidString(Object v) {\n    if (!(v instanceof String)) return false;\n    try { UUID.fromString((String) v); return true; } catch (IllegalArgumentException e) { return false; }\n}","tryCatchPattern":"try {\n    UUID v = (UUID) converter.getVariableValue(result);\n} catch (FlowableIllegalArgumentException e) {\n    // value was not a String; inspect and re-store as uuid.toString()\n}","preventionTips":["Store UUIDs as their toString() form in REST variables.","Validate UUID string format before conversion to avoid a secondary IllegalArgumentException.","Keep UUID-typed variables as UUID objects in the engine and convert only at the REST boundary."],"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"}