Skip to content

Propagate OperationResult in PayloadFieldIndex::filter - #8647

Merged
xzfc merged 1 commit into
devfrom
uio-propagate-result-filter
Apr 11, 2026
Merged

xzfc merged 1 commit into
devfrom
uio-propagate-result-filter

Conversation

@xzfc

@xzfc xzfc commented Apr 10, 2026

Copy link
Copy Markdown
Member

Continuation of #8433.
Will be used for #8507.

@xzfc
xzfc requested review from coszio, generall and timvisee April 10, 2026 16:12
@xzfc xzfc added this to the Universal IO milestone Apr 10, 2026
@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR changes many filter/query APIs to move error reporting from the function return into iterator items. Signatures that returned OperationResult<Option<Box<dyn Iterator<Item = PointOffsetType>>>> now return Option<Box<dyn Iterator<Item = OperationResult<PointOffsetType>>>>. Implementations across bool, numeric, map, geo, null, and full-text indexes, plus HNSW/searcher, struct payload indexing, and various consumers/tests, were updated to wrap per-item outputs with Ok(...) and to use filter_ok/filter_map_ok/process_results/try_fold-style flows where appropriate.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • generall
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.90% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Propagate OperationResult in PayloadFieldIndex::filter' is concise and clearly describes the primary change across all modified files.
Description check ✅ Passed The description references related PRs (#8433, #8507) and indicates this is a continuation of prior work, establishing clear context for the changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch uio-propagate-result-filter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
lib/segment/src/index/field_index/full_text_index/text_index.rs (1)

472-479: Avoid the catch-all arm in this Match selection.

The _ => return None arm on Line 478 means a newly added Match variant will silently bypass the full-text index instead of forcing an explicit decision at compile time.

As per coding guidelines, "Prefer explicit exhaustive matches over catch-all _ arm in Rust match expressions, so we don't miss handling new enum variants when they are added later".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/index/field_index/full_text_index/text_index.rs` around lines
472 - 479, Replace the catch-all arm in the match on condition.r#match inside
the function that returns Option<Box<dyn Iterator...>>: remove `_ => return
None` and instead enumerate all existing Match variants explicitly (e.g.
Match::Text, Match::Phrase, plus the other concrete variants present in the
Match enum), handling each variant with the appropriate behavior (call
parse_text_query or parse_phrase_query for text/phrase and return None or the
correct fallback for the other explicit variants). This makes the match
exhaustive so the compiler will force updates if new Match variants are added;
reference the existing parse_text_query and parse_phrase_query calls when
implementing the explicit arms.
lib/segment/src/index/field_index/map_index/mod.rs (1)

725-760: Make the new Match dispatch explicit instead of using _ => None.

The _ => None arms on Line 759, Line 934, and Line 1107 will silently treat any future Match variant as unsupported and skip index usage until someone notices. Enumerating the non-supported variants explicitly keeps that decision compile-time visible.

As per coding guidelines, "Prefer explicit exhaustive matches over catch-all _ arm in Rust match expressions, so we don't miss handling new enum variants when they are added later".

Also applies to: 875-935, 1073-1108

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/index/field_index/map_index/mod.rs` around lines 725 - 760,
The match on condition.r#match uses a catch-all `_ => None`, which hides future
new Match variants; replace the `_ => None` with explicit arms for each
remaining Match enum variant (e.g., Match::Prefix(...), Match::Range(...),
Match::Regex(...), etc.) returning None or appropriate behavior so that adding a
new variant will cause a compile-time error; update the same pattern in the
other occurrences (the match blocks around the Any/Except handling and the
similar matches at the other noted locations) to enumerate all non-supported
Match variants explicitly rather than using a catch-all.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/segment/src/index/field_index/full_text_index/inverted_index/mod.rs`:
- Line 217: The congruence helper at the bottom of the module is currently
comparing Vec<Result<...>> because the iterator from filter() yields Results;
change the helper to unwrap each yielded item before performing equality checks
(i.e., map or collect the iterator of OperationResult<PointOffsetType> and call
.unwrap() on each item so you compare the inner values), ensuring you unwrap the
items produced by filter() in the helper used by the full-text tests; reference
the iterator item type OperationResult<PointOffsetType> and the congruence
helper that consumes filter() results when making this change.

In `@lib/segment/src/segment/scroll.rs`:
- Around line 133-137: The pagination offset comparison in the filter_map_ok
closure currently keeps items where external_id == offset, but the scroll offset
is exclusive; change the check that uses id_tracker.external_id(internal_id) and
the offset variable so that when offset is Some(o) you exclude external_id <= o
(not just < o). Update the closure in the scroll path (the filter_map_ok block)
to match the exclusive semantics used by read_by_id_stream → iter_from_visible
so the offset value is not re-included in the next page.

---

Nitpick comments:
In `@lib/segment/src/index/field_index/full_text_index/text_index.rs`:
- Around line 472-479: Replace the catch-all arm in the match on
condition.r#match inside the function that returns Option<Box<dyn Iterator...>>:
remove `_ => return None` and instead enumerate all existing Match variants
explicitly (e.g. Match::Text, Match::Phrase, plus the other concrete variants
present in the Match enum), handling each variant with the appropriate behavior
(call parse_text_query or parse_phrase_query for text/phrase and return None or
the correct fallback for the other explicit variants). This makes the match
exhaustive so the compiler will force updates if new Match variants are added;
reference the existing parse_text_query and parse_phrase_query calls when
implementing the explicit arms.

In `@lib/segment/src/index/field_index/map_index/mod.rs`:
- Around line 725-760: The match on condition.r#match uses a catch-all `_ =>
None`, which hides future new Match variants; replace the `_ => None` with
explicit arms for each remaining Match enum variant (e.g., Match::Prefix(...),
Match::Range(...), Match::Regex(...), etc.) returning None or appropriate
behavior so that adding a new variant will cause a compile-time error; update
the same pattern in the other occurrences (the match blocks around the
Any/Except handling and the similar matches at the other noted locations) to
enumerate all non-supported Match variants explicitly rather than using a
catch-all.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4cb22dcf-81c0-4473-a8ba-8e15d77dcf3e

📥 Commits

Reviewing files that changed from the base of the PR and between e471bdf and 348711c.

📒 Files selected for processing (29)
  • lib/segment/src/index/field_index/bool_index/mod.rs
  • lib/segment/src/index/field_index/bool_index/mutable_bool_index.rs
  • lib/segment/src/index/field_index/field_index_base.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/immutable_inverted_index.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/mmap_inverted_index/mod.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/mod.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/mutable_inverted_index.rs
  • lib/segment/src/index/field_index/full_text_index/mutable_text_index.rs
  • lib/segment/src/index/field_index/full_text_index/tests/mod.rs
  • lib/segment/src/index/field_index/full_text_index/tests/test_congruence.rs
  • lib/segment/src/index/field_index/full_text_index/text_index.rs
  • lib/segment/src/index/field_index/geo_index/mod.rs
  • lib/segment/src/index/field_index/map_index/mod.rs
  • lib/segment/src/index/field_index/null_index/mutable_null_index.rs
  • lib/segment/src/index/field_index/numeric_index/mod.rs
  • lib/segment/src/index/field_index/numeric_index/tests.rs
  • lib/segment/src/index/hnsw_index/hnsw.rs
  • lib/segment/src/index/hnsw_index/point_scorer.rs
  • lib/segment/src/index/plain_vector_index.rs
  • lib/segment/src/index/sparse_index/sparse_vector_index.rs
  • lib/segment/src/index/struct_payload_index.rs
  • lib/segment/src/segment/facet.rs
  • lib/segment/src/segment/order_by.rs
  • lib/segment/src/segment/sampling.rs
  • lib/segment/src/segment/scroll.rs
  • lib/segment/src/vector_storage/dense/dense_vector_storage.rs
  • lib/segment/src/vector_storage/tests/test_appendable_dense_vector_storage.rs
  • lib/segment/src/vector_storage/tests/test_appendable_multi_dense_vector_storage.rs
  • lib/segment/src/vector_storage/tests/test_appendable_sparse_vector_storage.rs

Comment thread lib/segment/src/segment/scroll.rs Resolved
@xzfc
xzfc force-pushed the uio-propagate-result-filter branch from 348711c to 377c6d6 Compare April 10, 2026 17:29

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
lib/segment/src/segment/scroll.rs (1)

133-137: ⚠️ Potential issue | 🔴 Critical

Exclude the offset value from the next page.

This still keeps external_id == offset, so paginating with the last returned ID can repeat that same point forever when limit = 1. The index-based path needs the same exclusive offset semantics as iter_from_visible.

Suggested fix
             .filter_map_ok(|internal_id| {
                 let external_id = id_tracker.external_id(internal_id)?;
                 match offset {
-                    Some(offset) if external_id < offset => None,
-                    _ => Some(external_id),
+                    Some(offset) if external_id <= offset => None,
+                    Some(_) => Some(external_id),
+                    None => Some(external_id),
                 }
             });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/segment/scroll.rs` around lines 133 - 137, The index-based
paginator in the filter_map_ok closure still allows external_id == offset,
causing duplicates when limit = 1; update the conditional in the closure that
calls id_tracker.external_id(internal_id) so that when offset is Some(offset) it
excludes values <= offset (i.e., treat the offset as exclusive), mirroring the
exclusive semantics used by iter_from_visible; locate the closure in
segment::scroll (the filter_map_ok block that calls id_tracker.external_id) and
change the match/if condition to skip when external_id <= offset.
🧹 Nitpick comments (1)
lib/segment/src/index/field_index/full_text_index/text_index.rs (1)

473-479: Match Match exhaustively here.

Using _ => return None means a new Match variant will be silently ignored in production code. Please spell out the non-text variants explicitly so additions fail at compile time.

As per coding guidelines, "Prefer explicit exhaustive matches over catch-all _ arm in Rust match expressions, so we don't miss handling new enum variants when they are added later".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/index/field_index/full_text_index/text_index.rs` around lines
473 - 479, The match on condition.r#match currently uses a catch-all `_ =>
return None`, which hides future enum variants; replace the `_` arm by
explicitly listing every non-text Match variant from the Match enum (e.g.,
Match::Xyz, Match::Other, etc.) and have each of those arms return None (or
handle appropriately) so the match is exhaustive and the compiler will error if
new variants are added; keep the existing arms that call self.parse_text_query
and self.parse_phrase_query for Match::Text and Match::Phrase respectively
(referencing parse_text_query, parse_phrase_query and parsed_query_opt).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/segment/src/index/field_index/geo_index/mod.rs`:
- Around line 529-556: The code currently swallows errors from rectangle_hashes
/ circle_hashes / polygon_hashes by using .ok()? which turns construction
failures into None; instead, when rectangle_hashes, circle_hashes or
polygon_hashes returns Err, convert that error into an iterator that yields a
single Err item (so callers see the OperationResult error) rather than returning
None. Locate the branches that call rectangle_hashes, circle_hashes and
polygon_hashes inside the geo_* condition checks and replace the .ok()? usage
with logic that maps the Err into a boxed iterator producing that error
(matching the iterator item type used by self.iterator(...).filter_map_ok(...)
and compatible with check_values_any and filter_map_ok) so the failing hash
construction is emitted through the returned iterator instead of being dropped.

---

Duplicate comments:
In `@lib/segment/src/segment/scroll.rs`:
- Around line 133-137: The index-based paginator in the filter_map_ok closure
still allows external_id == offset, causing duplicates when limit = 1; update
the conditional in the closure that calls id_tracker.external_id(internal_id) so
that when offset is Some(offset) it excludes values <= offset (i.e., treat the
offset as exclusive), mirroring the exclusive semantics used by
iter_from_visible; locate the closure in segment::scroll (the filter_map_ok
block that calls id_tracker.external_id) and change the match/if condition to
skip when external_id <= offset.

---

Nitpick comments:
In `@lib/segment/src/index/field_index/full_text_index/text_index.rs`:
- Around line 473-479: The match on condition.r#match currently uses a catch-all
`_ => return None`, which hides future enum variants; replace the `_` arm by
explicitly listing every non-text Match variant from the Match enum (e.g.,
Match::Xyz, Match::Other, etc.) and have each of those arms return None (or
handle appropriately) so the match is exhaustive and the compiler will error if
new variants are added; keep the existing arms that call self.parse_text_query
and self.parse_phrase_query for Match::Text and Match::Phrase respectively
(referencing parse_text_query, parse_phrase_query and parsed_query_opt).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e90f78a1-bb75-42b4-8816-f5b3db9071f2

📥 Commits

Reviewing files that changed from the base of the PR and between 348711c and 377c6d6.

📒 Files selected for processing (29)
  • lib/segment/src/index/field_index/bool_index/mod.rs
  • lib/segment/src/index/field_index/bool_index/mutable_bool_index.rs
  • lib/segment/src/index/field_index/field_index_base.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/immutable_inverted_index.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/mmap_inverted_index/mod.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/mod.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/mutable_inverted_index.rs
  • lib/segment/src/index/field_index/full_text_index/mutable_text_index.rs
  • lib/segment/src/index/field_index/full_text_index/tests/mod.rs
  • lib/segment/src/index/field_index/full_text_index/tests/test_congruence.rs
  • lib/segment/src/index/field_index/full_text_index/text_index.rs
  • lib/segment/src/index/field_index/geo_index/mod.rs
  • lib/segment/src/index/field_index/map_index/mod.rs
  • lib/segment/src/index/field_index/null_index/mutable_null_index.rs
  • lib/segment/src/index/field_index/numeric_index/mod.rs
  • lib/segment/src/index/field_index/numeric_index/tests.rs
  • lib/segment/src/index/hnsw_index/hnsw.rs
  • lib/segment/src/index/hnsw_index/point_scorer.rs
  • lib/segment/src/index/plain_vector_index.rs
  • lib/segment/src/index/sparse_index/sparse_vector_index.rs
  • lib/segment/src/index/struct_payload_index.rs
  • lib/segment/src/segment/facet.rs
  • lib/segment/src/segment/order_by.rs
  • lib/segment/src/segment/sampling.rs
  • lib/segment/src/segment/scroll.rs
  • lib/segment/src/vector_storage/dense/dense_vector_storage.rs
  • lib/segment/src/vector_storage/tests/test_appendable_dense_vector_storage.rs
  • lib/segment/src/vector_storage/tests/test_appendable_multi_dense_vector_storage.rs
  • lib/segment/src/vector_storage/tests/test_appendable_sparse_vector_storage.rs
✅ Files skipped from review due to trivial changes (6)
  • lib/segment/src/vector_storage/tests/test_appendable_sparse_vector_storage.rs
  • lib/segment/src/index/field_index/numeric_index/tests.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/mutable_inverted_index.rs
  • lib/segment/src/index/field_index/full_text_index/tests/test_congruence.rs
  • lib/segment/src/index/field_index/full_text_index/mutable_text_index.rs
  • lib/segment/src/segment/order_by.rs
🚧 Files skipped from review as they are similar to previous changes (12)
  • lib/segment/src/vector_storage/tests/test_appendable_multi_dense_vector_storage.rs
  • lib/segment/src/index/field_index/full_text_index/tests/mod.rs
  • lib/segment/src/segment/sampling.rs
  • lib/segment/src/vector_storage/dense/dense_vector_storage.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/immutable_inverted_index.rs
  • lib/segment/src/vector_storage/tests/test_appendable_dense_vector_storage.rs
  • lib/segment/src/index/field_index/bool_index/mutable_bool_index.rs
  • lib/segment/src/index/field_index/null_index/mutable_null_index.rs
  • lib/segment/src/index/field_index/field_index_base.rs
  • lib/segment/src/index/sparse_index/sparse_vector_index.rs
  • lib/segment/src/index/field_index/full_text_index/inverted_index/mmap_inverted_index/mod.rs
  • lib/segment/src/index/field_index/map_index/mod.rs

Comment on lines 529 to +556
if let Some(geo_bounding_box) = &condition.geo_bounding_box {
let Some(geo_hashes) = rectangle_hashes(geo_bounding_box, GEO_QUERY_MAX_REGION).ok()
else {
return Ok(None);
};
let geo_hashes = rectangle_hashes(geo_bounding_box, GEO_QUERY_MAX_REGION).ok()?;
let geo_condition_copy = *geo_bounding_box;
return Ok(Some(Box::new(self.iterator(geo_hashes)?.filter(
return Some(Box::new(self.iterator(geo_hashes).filter_map_ok(
move |point| {
self.check_values_any(*point, hw_counter, |geo_point| {
self.check_values_any(point, hw_counter, |geo_point| {
geo_condition_copy.check_point(geo_point)
})
.then_some(point)
},
))));
)));
}

if let Some(geo_radius) = &condition.geo_radius {
let Some(geo_hashes) = circle_hashes(geo_radius, GEO_QUERY_MAX_REGION).ok() else {
return Ok(None);
};
let geo_hashes = circle_hashes(geo_radius, GEO_QUERY_MAX_REGION).ok()?;
let geo_condition_copy = *geo_radius;
return Ok(Some(Box::new(self.iterator(geo_hashes)?.filter(
return Some(Box::new(self.iterator(geo_hashes).filter_map_ok(
move |point| {
self.check_values_any(*point, hw_counter, |geo_point| {
self.check_values_any(point, hw_counter, |geo_point| {
geo_condition_copy.check_point(geo_point)
})
.then_some(point)
},
))));
)));
}

if let Some(geo_polygon) = &condition.geo_polygon {
let Some(geo_hashes) = polygon_hashes(geo_polygon, GEO_QUERY_MAX_REGION).ok() else {
return Ok(None);
};
let geo_hashes = polygon_hashes(geo_polygon, GEO_QUERY_MAX_REGION).ok()?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don’t drop geo hash construction failures.

These branches turn rectangle_hashes / circle_hashes / polygon_hashes errors into None via .ok()?. That makes a failing geo filter look the same as “index not applicable”, so callers can silently fall back instead of surfacing the failure. This PR is moving OperationResult into iterator items, so these errors should be emitted through the returned iterator, not discarded.

Suggested direction
         if let Some(geo_bounding_box) = &condition.geo_bounding_box {
-            let geo_hashes = rectangle_hashes(geo_bounding_box, GEO_QUERY_MAX_REGION).ok()?;
+            let geo_hashes = match rectangle_hashes(geo_bounding_box, GEO_QUERY_MAX_REGION) {
+                Ok(hashes) => hashes,
+                Err(err) => return Some(Box::new(std::iter::once(Err(err.into())))),
+            };
             let geo_condition_copy = *geo_bounding_box;
             return Some(Box::new(self.iterator(geo_hashes).filter_map_ok(
                 move |point| {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if let Some(geo_bounding_box) = &condition.geo_bounding_box {
let Some(geo_hashes) = rectangle_hashes(geo_bounding_box, GEO_QUERY_MAX_REGION).ok()
else {
return Ok(None);
};
let geo_hashes = rectangle_hashes(geo_bounding_box, GEO_QUERY_MAX_REGION).ok()?;
let geo_condition_copy = *geo_bounding_box;
return Ok(Some(Box::new(self.iterator(geo_hashes)?.filter(
return Some(Box::new(self.iterator(geo_hashes).filter_map_ok(
move |point| {
self.check_values_any(*point, hw_counter, |geo_point| {
self.check_values_any(point, hw_counter, |geo_point| {
geo_condition_copy.check_point(geo_point)
})
.then_some(point)
},
))));
)));
}
if let Some(geo_radius) = &condition.geo_radius {
let Some(geo_hashes) = circle_hashes(geo_radius, GEO_QUERY_MAX_REGION).ok() else {
return Ok(None);
};
let geo_hashes = circle_hashes(geo_radius, GEO_QUERY_MAX_REGION).ok()?;
let geo_condition_copy = *geo_radius;
return Ok(Some(Box::new(self.iterator(geo_hashes)?.filter(
return Some(Box::new(self.iterator(geo_hashes).filter_map_ok(
move |point| {
self.check_values_any(*point, hw_counter, |geo_point| {
self.check_values_any(point, hw_counter, |geo_point| {
geo_condition_copy.check_point(geo_point)
})
.then_some(point)
},
))));
)));
}
if let Some(geo_polygon) = &condition.geo_polygon {
let Some(geo_hashes) = polygon_hashes(geo_polygon, GEO_QUERY_MAX_REGION).ok() else {
return Ok(None);
};
let geo_hashes = polygon_hashes(geo_polygon, GEO_QUERY_MAX_REGION).ok()?;
if let Some(geo_bounding_box) = &condition.geo_bounding_box {
let geo_hashes = match rectangle_hashes(geo_bounding_box, GEO_QUERY_MAX_REGION) {
Ok(hashes) => hashes,
Err(err) => return Some(Box::new(std::iter::once(Err(err.into())))),
};
let geo_condition_copy = *geo_bounding_box;
return Some(Box::new(self.iterator(geo_hashes).filter_map_ok(
move |point| {
self.check_values_any(point, hw_counter, |geo_point| {
geo_condition_copy.check_point(geo_point)
})
.then_some(point)
},
)));
}
if let Some(geo_radius) = &condition.geo_radius {
let geo_hashes = match circle_hashes(geo_radius, GEO_QUERY_MAX_REGION) {
Ok(hashes) => hashes,
Err(err) => return Some(Box::new(std::iter::once(Err(err.into())))),
};
let geo_condition_copy = *geo_radius;
return Some(Box::new(self.iterator(geo_hashes).filter_map_ok(
move |point| {
self.check_values_any(point, hw_counter, |geo_point| {
geo_condition_copy.check_point(geo_point)
})
.then_some(point)
},
)));
}
if let Some(geo_polygon) = &condition.geo_polygon {
let geo_hashes = match polygon_hashes(geo_polygon, GEO_QUERY_MAX_REGION) {
Ok(hashes) => hashes,
Err(err) => return Some(Box::new(std::iter::once(Err(err.into())))),
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/index/field_index/geo_index/mod.rs` around lines 529 - 556,
The code currently swallows errors from rectangle_hashes / circle_hashes /
polygon_hashes by using .ok()? which turns construction failures into None;
instead, when rectangle_hashes, circle_hashes or polygon_hashes returns Err,
convert that error into an iterator that yields a single Err item (so callers
see the OperationResult error) rather than returning None. Locate the branches
that call rectangle_hashes, circle_hashes and polygon_hashes inside the geo_*
condition checks and replace the .ok()? usage with logic that maps the Err into
a boxed iterator producing that error (matching the iterator item type used by
self.iterator(...).filter_map_ok(...) and compatible with check_values_any and
filter_map_ok) so the failing hash construction is emitted through the returned
iterator instead of being dropped.

@xzfc
xzfc merged commit 4816557 into dev Apr 11, 2026
15 checks passed
@xzfc
xzfc deleted the uio-propagate-result-filter branch April 11, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants