Fix id field filter value parsing crash. (#1817)

This commit is contained in:
Harpreet Sangar 2024-07-02 21:42:55 +05:30 committed by GitHub
parent 6cb6a07891
commit 6189fec042
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -459,6 +459,10 @@ Option<bool> toFilter(const std::string expression,
} else {
std::vector<std::string> doc_ids;
StringUtils::split_to_values(raw_value, doc_ids); // to handle backticks
if (doc_ids.empty()) {
return Option<bool>(400, empty_filter_err);
}
std::string seq_id_str;
StoreStatus seq_id_status = store->get(doc_id_prefix + doc_ids[0], seq_id_str);
if (seq_id_status == StoreStatus::FOUND) {

View File

@ -1399,6 +1399,10 @@ TEST_F(CollectionFilteringTest, FilteringViaDocumentIds) {
ASSERT_FALSE(res_op.ok());
ASSERT_EQ("Error with filter field `id`: Filter value cannot be empty.", res_op.error());
res_op = coll1->search("*", {}, "id: ``", {}, sort_fields, {0}, 10, 1, FREQUENCY, {true});
ASSERT_FALSE(res_op.ok());
ASSERT_EQ("Error with filter field `id`: Filter value cannot be empty.", res_op.error());
// when no IDs exist
results = coll1->search("*",
{}, "id: [1000] && num_employees: <300",