From fe5a5a813fb92606d4fa804d81530ea73b1cf54c Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Thu, 9 Apr 2026 11:22:57 +0300 Subject: [PATCH] alternator, vector: add validation of non-finite numbers in Query Non-finite numbers (Inf, NaN) don't make sense in vector search, and also not allowed in the DynamoDB API as numbers. But the parsing code in Query's QueryVector accepted "Inf" and "NaN" and then failed to send the request to the vector store, resulting in a strange error message. Let's fix it in the parsing code. We have a test (test_query_vectorsearch_queryvector_bad_number_string) that verifies this fix. Signed-off-by: Nadav Har'El --- alternator/executor_read.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alternator/executor_read.cc b/alternator/executor_read.cc index 3e9d6cd778..a35960c49c 100644 --- a/alternator/executor_read.cc +++ b/alternator/executor_read.cc @@ -1313,7 +1313,7 @@ static future query_vector( std::string_view num_str = rjson::to_string_view(*n_val); float f; auto [ptr, ec] = std::from_chars(num_str.data(), num_str.data() + num_str.size(), f); - if (ec != std::errc{} || ptr != num_str.data() + num_str.size()) { + if (ec != std::errc{} || ptr != num_str.data() + num_str.size() || !std::isfinite(f)) { co_return api_error::validation( format("VectorSearch QueryVector element '{}' is not a valid number", num_str)); }