Skip to content

[8.2] MOD-13948: Fix indexing discrepancy w.r.t the index filter#8601

Merged
raz-mon merged 1 commit into8.2from
backport-MOD-13948-to-8.2
Mar 10, 2026
Merged

[8.2] MOD-13948: Fix indexing discrepancy w.r.t the index filter#8601
raz-mon merged 1 commit into8.2from
backport-MOD-13948-to-8.2

Conversation

@raz-mon
Copy link
Copy Markdown
Collaborator

@raz-mon raz-mon commented Mar 4, 2026

Summary

Backport of commit 2ed1841 from master to 8.2 branch.

This PR fixes an indexing discrepancy where documents were incorrectly indexed when the filter expression evaluation should have failed (e.g., due to missing fields).

Related Jira: MOD-14340
Original PR: #8320

Conflicts Resolved

The following conflicts were encountered during the cherry-pick and resolved as follows:

1. src/aggregate/expr/expression.c

  • Conflict: In EvalCtx_Create(), the 8.2 branch had RLookup_Init(&r->lk, NULL), RLookupRow _row = {0}; r->row = _row;, and QueryError _status = {0} initialization calls, while the MOD-13948 commit removes the RLookup/Row initialization and changes to QueryError _status = QueryError_Default().
  • Resolution: Removed the RLookup/Row initialization as intended by MOD-13948. Kept QueryError _status = {0}; instead of QueryError_Default() since QueryError_Default() is not available in 8.2.

2. src/rules.c

  • Conflict: The 8.2 branch used manual EvalCtx_EvalExpr and RSValue_BoolTest calls, while MOD-13948 introduces the centralized SchemaRule_FilterPasses function.
  • Resolution: Accepted the incoming change to use SchemaRule_FilterPasses. Fixed call to RSValue_BoolTest(&r->res) (passing address instead of value) since RSValue_BoolTest expects const RSValue *.

3. src/spec.c

  • Conflict: Similar to rules.c - the 8.2 branch used manual eval/bool-test logic with different condition structure.
  • Resolution: Accepted the incoming change to use SchemaRule_FilterPasses with the correct negation logic.

4. tests/pytests/test_filter.py

  • Conflict: Modify/delete conflict - the file did not exist in 8.2 HEAD but was modified in the incoming commit.
  • Resolution: Added the file from the incoming commit since it contains the new test cases for testFilterWithMissingFields.

Pull Request opened by Augment Code with guidance from the PR author


Note

Medium Risk
Changes core indexing eligibility logic for rule filters, which can alter which documents are indexed/unindexed in edge cases (evaluation errors/NULLs). Covered by a focused regression test but could impact existing deployments relying on prior buggy behavior.

Overview
Fixes a discrepancy where documents could be indexed even when a schema rule FILTER expression could not be evaluated (e.g., missing fields).

This centralizes filter evaluation in new SchemaRule_FilterPasses() and updates both SchemaRule_ShouldIndex() and the spec-matching logic in Indexes_FindMatchingSchemaRules() to treat evaluation failures as filter not passing (skip/delete), rather than accidentally indexing. Adds a regression test (testFilterWithMissingFields) to cover pre/post-index document creation and subsequent updates.

Written by Cursor Bugbot for commit 6fb0e5f. This will update automatically on new commits. Configure here.

@raz-mon raz-mon requested review from nafraf and oshadmi March 4, 2026 11:28
@github-actions github-actions Bot added the size:L label Mar 4, 2026
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Mar 4, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@raz-mon raz-mon force-pushed the backport-MOD-13948-to-8.2 branch from dacd135 to 283b43e Compare March 10, 2026 13:55
@raz-mon
Copy link
Copy Markdown
Collaborator Author

raz-mon commented Mar 10, 2026

Approved by me.

* Fix incoherent indexing w.r.t index filter for index creation vs. updates/writes

* Add test for unified behavior

* Load from correct key when replacing (rename)

* Remove EVAL_EXPR_NULL

* Fix bug - json index interferes with hash index and vice-versa

* Remove unecessary initialization

* Fix exists function

* Revert the removal of EXPR_EVAL_NULL

* Fix bad reuse of RLookUp and RLookUpRow

* Remove split PRs' code

* Remove more for splitting

* Fix loaded document in rename flow

* Address review

* Add test

* Fix FILTER bug with multiple indexes with the same field alias

* Move test
@raz-mon raz-mon force-pushed the backport-MOD-13948-to-8.2 branch from 283b43e to 6fb0e5f Compare March 10, 2026 14:13
@sonarqubecloud
Copy link
Copy Markdown

@raz-mon raz-mon enabled auto-merge March 10, 2026 14:34
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.95%. Comparing base (aca71e1) to head (6fb0e5f).
⚠️ Report is 1 commits behind head on 8.2.

Additional details and impacted files
@@            Coverage Diff             @@
##              8.2    #8601      +/-   ##
==========================================
- Coverage   88.96%   88.95%   -0.01%     
==========================================
  Files         260      260              
  Lines       41992    41990       -2     
  Branches     3851     3851              
==========================================
- Hits        37358    37354       -4     
- Misses       4585     4587       +2     
  Partials       49       49              
Flag Coverage Δ
flow 82.02% <100.00%> (-0.65%) ⬇️
unit 46.77% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raz-mon raz-mon added this pull request to the merge queue Mar 10, 2026
Merged via the queue into 8.2 with commit 0ab6437 Mar 10, 2026
32 of 35 checks passed
@raz-mon raz-mon deleted the backport-MOD-13948-to-8.2 branch March 10, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants