{"record":{"id":"dbdfd848fc9132a4","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-string-to-localdate","errorCode":null,"errorMessage":"Converter can only convert string to localDate","messagePattern":"Converter can only convert string to localDate","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/LocalDateRestVariableConverter.java","lineNumber":39,"sourceCode":" * @author Filip Hrisafov\n */\npublic class LocalDateRestVariableConverter implements RestVariableConverter {\n\n    @Override\n    public String getRestTypeName() {\n        return \"localDate\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        return LocalDate.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 localDate\");\n            }\n            try {\n                return LocalDate.parse((String) result.getValue());\n            } catch (DateTimeParseException e) {\n                throw new FlowableIllegalArgumentException(\"The given variable value is not a localDate: '\" + 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 LocalDate)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert localDate\");\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/LocalDateRestVariableConverter.java#L21-L57","documentation":"LocalDateRestVariableConverter.getVariableValue deserializes a REST variable into a java.time.LocalDate and requires the REST value to be a String. If the incoming value is any other type it throws FlowableIllegalArgumentException, because only ISO-8601 strings (e.g. \"2026-09-10\") can be parsed via LocalDate.parse.","triggerScenarios":"Sending a REST variable of type localDate whose JSON value is a number, boolean, array, object, or already-parsed date instead of a string, so result.getValue() is not a String when getVariableValue runs.","commonSituations":"Clients posting variables with unquoted JSON dates or epoch millis; REST frameworks deserializing dates into non-String types before the converter sees them; sending LocalDateTime or datetime-with-timezone strings to a localDate variable.","solutions":["Send the value as an ISO-8601 date string (yyyy-MM-dd) in the REST payload.","Check the variable's type marker in the request matches localDate and the value field is a JSON string.","If the client sends epoch millis or full datetimes, convert/trim them to yyyy-MM-dd strings client-side before posting.","Fix client serialization config that renders LocalDate as arrays or numbers (e.g. Jackson WRITE_DATES_AS_TIMESTAMPS)."],"exampleFix":"// before\n{ \"type\": \"localDate\", \"value\": 1757462400000 }\n\n// after\n{ \"type\": \"localDate\", \"value\": \"2026-09-10\" }","handlingStrategy":"validation","validationCode":"if (!(rawValue instanceof String s)) {\n    throw new IllegalArgumentException(\"localDate variable must be a JSON string, got: \"\n        + (rawValue == null ? \"null\" : rawValue.getClass().getSimpleName()));\n}\nLocalDate.parse(s); // fail fast on format before calling the API","typeGuard":"static boolean isIsoLocalDateString(Object v) {\n    return v instanceof String s && s.matches(\"\\\\d{4}-\\\\d{2}-\\\\d{2}\");\n}","tryCatchPattern":"try {\n    Object value = converter.getVariableValue(restVar);\n} catch (FlowableIllegalArgumentException e) {\n    // value was not a String or not a valid ISO date; inspect restVar.getValue()\n    log.error(\"Invalid localDate variable: {}\", restVar.getValue(), e);\n}","preventionTips":["Always send dates as quoted ISO-8601 strings (yyyy-MM-dd).","Disable timestamp/array date serialization in client JSON mappers.","Validate payload schemas (string type for localDate) before POSTing variables."],"tags":["localdate","rest-variable","type-mismatch","date"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}