{"record":{"id":"eeed8d88c64d386c","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-string-to-instant","errorCode":null,"errorMessage":"Converter can only convert string to instant","messagePattern":"Converter can only convert string to instant","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/InstantRestVariableConverter.java","lineNumber":39,"sourceCode":" * @author Filip Hrisafov\n */\npublic class InstantRestVariableConverter implements RestVariableConverter {\n\n    @Override\n    public String getRestTypeName() {\n        return \"instant\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        return Instant.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 string to instant\");\n            }\n            try {\n                return Instant.parse((String) result.getValue());\n            } catch (DateTimeParseException e) {\n                throw new FlowableIllegalArgumentException(\"The given variable value is not an instant: '\" + result.getValue() + \"'\", e);\n            }\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof Instant)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert instant\");\n            }\n            result.setValue(variableValue.toString());\n        } else {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/InstantRestVariableConverter.java#L21-L57","documentation":"InstantRestVariableConverter.getVariableValue parses a String into java.time.Instant using Instant.parse (ISO-8601 instant format). If the stored value is non-null but not a String, it throws this FlowableIllegalArgumentException because only strings can be parsed.","triggerScenarios":"Reading a REST variable typed as 'instant' when the engine value is not a String (e.g. java.util.Date, Instant object, or number).","commonSituations":"Variable stored by the engine as Date but served through the instant converter; custom code setting the variable as an Instant object; type name mismatch between stored and requested REST type.","solutions":["Request the variable with the REST type matching the stored value (e.g. 'date' for java.util.Date).","Store the variable as an ISO-8601 instant string (e.g. 2026-09-10T00:00:00Z).","Convert the value with Instant.toString() before storing if custom code populates it.","Check for converter type-name collisions in the REST variable converter registry."],"exampleFix":"// before\nruntimeService.setVariable(executionId, \"firedAt\", new Date()); // served via instant converter\n// after\nruntimeService.setVariable(executionId, \"firedAt\", Instant.now().toString());","handlingStrategy":"type-guard","validationCode":"public static boolean isInstantString(Object v) { return v == null || v instanceof String; }","typeGuard":"public static boolean isString(Object v) { return v instanceof String; }","tryCatchPattern":"try {\n    Object ts = restClient.getVariable(id, \"firedAt\");\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().equals(\"Converter can only convert string to instant\")) {\n        // request the variable with the correct REST type or re-store as ISO string\n    } else { throw e; }\n}","preventionTips":["Store instant variables as ISO-8601 strings or as java.time.Instant with a matching converter.","Match the requested REST type ('instant' vs 'date') to the stored Java type.","Avoid mixing Date and Instant conventions across services."],"tags":["rest","instant","type-mismatch","variable-converter"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}