{"record":{"id":"c26f809ddb02cdf2","repo":"spring-projects/spring-ai","slug":"invalid-date-type","errorCode":null,"errorMessage":"Invalid date type: ","messagePattern":"Invalid date type: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-vector-store/src/main/java/org/springframework/ai/vectorstore/filter/converter/AbstractFilterExpressionConverter.java","lineNumber":185,"sourceCode":"\t\t}\n\t}\n\n\t/**\n\t * If the value is a string matching the ISO date pattern, parse and return as\n\t * {@link Date} so that all converters that handle {@code Date} automatically support\n\t * date strings. Otherwise return the value unchanged.\n\t * @param value the value (possibly a date string)\n\t * @return the value, or a {@code Date} if the value was a parseable date string\n\t */\n\tprotected static Object normalizeDateString(Object value) {\n\t\tif (!(value instanceof String text) || !ISO_DATE_PATTERN.matcher(text).matches()) {\n\t\t\treturn value;\n\t\t}\n\t\ttry {\n\t\t\treturn Date.from(Instant.from(ISO_DATE_FORMATTER.parse(text)));\n\t\t}\n\t\tcatch (DateTimeParseException e) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid date type: \" + text, e);\n\t\t}\n\t}\n\n\t/**\n\t * Convert the given single value into a string representation and append it to the\n\t * context. This method handles all value types including String, Number, Boolean,\n\t * Date, etc.\n\t * <p>\n\t * For convenience, implementations can use the provided static helper methods such as\n\t * {@link #emitJsonValue(Object, StringBuilder)} for JSON-based filters,\n\t * {@link #emitLuceneString(String, StringBuilder)} for Lucene-based filters, or\n\t * implement their own format-specific escaping logic as needed.\n\t * @param value the value to convert\n\t * @param context the context to append the string representation to\n\t */\n\tprotected abstract void doSingleValue(Object value, StringBuilder context);\n\n\t/**","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/spring-ai-vector-store/src/main/java/org/springframework/ai/vectorstore/filter/converter/AbstractFilterExpressionConverter.java#L167-L203","documentation":"normalizeDateString normalizes date values in filter expressions to java.util.Date using ISO_DATE_FORMATTER. If the text cannot be parsed as an ISO date it throws IllegalArgumentException(\"Invalid date type: \" + text). This validates that date-typed filter values are real ISO-formatted dates.","triggerScenarios":"Using a date string value in a filter (e.g. \"createdAt > <date>\") where the value text reaching normalizeDateString (via doValue) is not ISO format — e.g. \"01/15/2024\", \"Jan 15 2024\", or an impossible date like \"2024-13-45\" — causing DateTimeParseException.","commonSituations":"US-style date formats in filter strings; locale-specific dates; user-supplied dates passed straight into filter expressions; typos like 2024-1-5 without zero padding.","solutions":["Use ISO-8601 date format (yyyy-MM-dd or full ISO date-time) in filter date values, e.g. \"createdAt > 2024-01-15\"","Pre-parse your date in application code with LocalDate.parse(..., DateTimeFormatter.ISO_LOCAL_DATE) to validate before building the filter","Catch IllegalArgumentException and prompt the user with the expected ISO format"],"exampleFix":"// before\nparser.parse(\"createdAt > 01/15/2024\");\n// after\nparser.parse(\"createdAt > 2024-01-15\");","handlingStrategy":"validation","validationCode":"try { LocalDate.parse(dateText, DateTimeFormatter.ISO_LOCAL_DATE); }\ncatch (DateTimeParseException e) { throw new IllegalArgumentException(\"Use ISO date: yyyy-MM-dd\"); }","typeGuard":null,"tryCatchPattern":"try { filter = parser.parse(text); }\ncatch (IllegalArgumentException e) { throw new IllegalArgumentException(\"Invalid date in filter, expected ISO format: \" + e.getMessage(), e); }","preventionTips":["Always emit ISO-8601 dates in filter strings","Validate dates with java.time before building filters"],"tags":["filter-expression","date-parsing","vector-store"],"backgroundTag":"invalid-date-format","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}