{"record":{"id":"88d63dc7343fc92a","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-instant","errorCode":null,"errorMessage":"Converter can only convert instant","messagePattern":"Converter can only convert 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":54,"sourceCode":"    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 {\n            result.setValue(null);\n        }\n    }\n\n}\n","sourceCodeStart":36,"sourceCodeEnd":63,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/InstantRestVariableConverter.java#L36-L63","documentation":"InstantRestVariableConverter.convertVariableValue serializes a java.time.Instant to its string form for the REST response. A non-null value that is not an Instant causes this FlowableIllegalArgumentException.","triggerScenarios":"REST layer hands the instant converter a non-Instant object (String, Date, Long epoch millis) because the value's declared REST type is 'instant' but the deserialized Java object is something else.","commonSituations":"Clients writing epoch-millis or Date-typed values under the 'instant' type; custom converters misregistered for java.time.Instant; version migration where Date variables are now requested as instant.","solutions":["Convert the value to Instant before conversion (e.g. ((Date) v).toInstant(), or Instant.ofEpochMilli(long)).","Send/write the value as an ISO-8601 instant string and let the engine store an Instant.","Use the 'date' REST type if the underlying object is java.util.Date.","Audit custom variable converter registrations for a collision on the instant type name."],"exampleFix":"// before\nconverter.convertVariableValue(new Date(), result);\n// after\nconverter.convertVariableValue(new Date().toInstant(), result);","handlingStrategy":"type-guard","validationCode":"public static boolean isInstantValue(Object v) { return v == null || v instanceof java.time.Instant; }","typeGuard":"public static java.time.Instant asInstant(Object v) {\n    if (v instanceof java.time.Instant i) return i;\n    if (v instanceof java.util.Date d) return d.toInstant();\n    if (v instanceof Long m) return java.time.Instant.ofEpochMilli(m);\n    return null;\n}","tryCatchPattern":"try {\n    converter.convertVariableValue(value, restVariable);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().equals(\"Converter can only convert instant\")) {\n        converter.convertVariableValue(asInstant(value), restVariable);\n    } else { throw e; }\n}","preventionTips":["Pass java.time.Instant only to the instant converter.","Convert legacy java.util.Date values with toInstant() first.","Use the 'date' REST type when the value is a java.util.Date."],"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"}