{"record":{"id":"d9da8c3c714fdbd4","repo":"spring-projects/spring-ai","slug":"unsupported-number-type","errorCode":null,"errorMessage":"Unsupported Number type: ","messagePattern":"Unsupported Number type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-s3-vector-store/src/main/java/org/springframework/ai/vectorstore/s3/S3VectorFilterSearchExpressionConverter.java","lineNumber":151,"sourceCode":"\t\tif (num instanceof Integer i) {\n\t\t\treturn SdkNumber.fromInteger(i);\n\t\t}\n\t\tif (num instanceof Long l) {\n\t\t\treturn SdkNumber.fromLong(l);\n\t\t}\n\t\tif (num instanceof Double d) {\n\t\t\treturn SdkNumber.fromDouble(d);\n\t\t}\n\t\tif (num instanceof Float f) {\n\t\t\treturn SdkNumber.fromFloat(f);\n\t\t}\n\t\tif (num instanceof Short s) {\n\t\t\treturn SdkNumber.fromShort(s);\n\t\t}\n\t\tif (num instanceof Byte b) {\n\t\t\treturn SdkNumber.fromInteger(b.intValue());\n\t\t}\n\t\tthrow new IllegalArgumentException(\"Unsupported Number type: \" + num.getClass());\n\t}\n\n}\n","sourceCodeStart":133,"sourceCodeEnd":155,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-s3-vector-store/src/main/java/org/springframework/ai/vectorstore/s3/S3VectorFilterSearchExpressionConverter.java#L133-L155","documentation":"toSdkNumber converts a java.lang.Number to an AWS SDK SdkNumber for filter values. It handles BigDecimal, Integer, Long, Double, Float, Short, and Byte; any other Number subtype (e.g. BigInteger, AtomicInteger, or a custom Number) throws IllegalArgumentException.","triggerScenarios":"Using IN/NIN/EQ/GT etc. filter values that are Number instances outside the supported set — most commonly java.math.BigInteger (e.g. from JSON parsers or ID generators) or AtomicInteger — in a SearchRequest filter passed to S3VectorStore.similaritySearch.","commonSituations":"Parsing metadata IDs with Jackson into BigInteger; using Atomic counters as filter values; framework deserializers that produce exotic Number subtypes; metadata values typed as Number that at runtime hold BigInteger.","solutions":["Convert the value to a supported type before filtering, e.g. bigInteger.longValueExact() or intValue().","Store the metadata value as a standard long/int/double so filter comparisons use supported types.","Normalize filter values in one place: a helper that maps any Number to Long/Double before building the SearchRequest.","Add a BigInteger branch to toSdkNumber (SdkNumber.fromBigDecimal(BigInteger to BigDecimal)) if you maintain a fork."],"exampleFix":"// before\nFilter.Value value = new Filter.Value(bigIntegerId);\n// after\nFilter.Value value = new Filter.Value(bigIntegerId.longValueExact());","handlingStrategy":"type-guard","validationCode":"static boolean isSdkConvertible(Number n) { return n instanceof BigDecimal || n instanceof Integer || n instanceof Long || n instanceof Double || n instanceof Float || n instanceof Short || n instanceof Byte; }","typeGuard":"static Number toSafeNumber(Number n) { return (n instanceof BigInteger b) ? b.longValueExact() : n; }","tryCatchPattern":"try { store.similaritySearch(req); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported Number type\")) { /* rebuild filter with normalized numbers */ } }","preventionTips":["Normalize all numeric filter values to int/long/double before building filters.","Configure JSON deserializers to map integral values to Long, not BigInteger.","Avoid AtomicInteger/AtomicLong as filter literals."],"tags":["vector-store","filter-expression","number-conversion","aws-sdk","aws-s3-vectors"],"backgroundTag":"unsupported-dtype","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}