Repository navigation
fix: include documents without the metadata key in negative metadata filters - #44753
Merged
asukaminato0721 merged 4 commits intoOct 26, 2026
Conversation
6 tasks done
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-10-26 03:04:29.603022635 +0000
+++ /tmp/pyrefly_pr.txt 2026-10-26 03:04:18.582986803 +0000
@@ -4247,71 +4247,71 @@
ERROR Object of class `FunctionType` has no attribute `return_value` [missing-attribute]
--> tests/unit_tests/core/rag/rerank/test_rerank_model.py:1847:9
ERROR Unpacked keyword argument `object` is not assignable to parameter `id` with type `SQLCoreOperations[str] | str` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `tenant_id` with type `SQLCoreOperations[str] | str` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `name` with type `SQLCoreOperations[str] | str` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `description` with type `SQLCoreOperations[str | None] | str | None` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `provider` with type `SQLCoreOperations[str] | str` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `created_by` with type `SQLCoreOperations[str] | str` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `maintainer` with type `SQLCoreOperations[str | None] | str | None` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `updated_by` with type `SQLCoreOperations[str | None] | str | None` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `built_in_field_enabled` with type `SQLCoreOperations[bool] | bool` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `enable_api` with type `SQLCoreOperations[bool] | bool` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Unpacked keyword argument `object` is not assignable to parameter `is_multimodal` with type `SQLCoreOperations[bool] | bool` in function `models.dataset.Dataset.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:117:20
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:118:20
ERROR Argument `_FakeFlaskApp` is not assignable to parameter `flask_app` with type `Flask` in function `core.rag.retrieval.dataset_retrieval.DatasetRetrieval._run_retriever_thread` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:3868:31
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:3869:31
ERROR Argument `_FakeFlaskApp` is not assignable to parameter `flask_app` with type `Flask` in function `core.rag.retrieval.dataset_retrieval.DatasetRetrieval._run_retriever_thread_safely` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:3890:31
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:3891:31
ERROR Argument `_FakeFlaskApp` is not assignable to parameter `flask_app` with type `Flask` in function `core.rag.retrieval.dataset_retrieval.DatasetRetrieval._run_retriever_thread_safely` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:3914:31
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:3915:31
ERROR `SimpleNamespace` is not assignable to attribute `application_generate_entity` with type `EasyUIBasedAppGenerateEntity | None` [bad-assignment]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4061:53
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4097:53
ERROR Argument `Literal['completed']` is not assignable to parameter `indexing_status` with type `IndexingStatus | SQLCoreOperations[IndexingStatus]` in function `models.dataset.Document.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4355:37
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4391:37
ERROR Argument `Literal['completed']` is not assignable to parameter `indexing_status` with type `IndexingStatus | SQLCoreOperations[IndexingStatus]` in function `models.dataset.Document.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4483:37
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4519:37
ERROR Object of class `FunctionType` has no attribute `return_value` [missing-attribute]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4708:13
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4744:13
ERROR Argument `Literal['completed']` is not assignable to parameter `indexing_status` with type `IndexingStatus | SQLCoreOperations[IndexingStatus]` in function `models.dataset.Document.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4843:33
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4879:33
ERROR Argument `Literal['completed']` is not assignable to parameter `status` with type `SQLCoreOperations[SegmentStatus] | SegmentStatus` in function `models.dataset.DocumentSegment.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4859:24
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:4895:24
ERROR Argument `Literal['completed']` is not assignable to parameter `indexing_status` with type `IndexingStatus | SQLCoreOperations[IndexingStatus]` in function `models.dataset.Document.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5426:37
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5462:37
ERROR Argument `Literal['completed']` is not assignable to parameter `status` with type `SQLCoreOperations[SegmentStatus] | SegmentStatus` in function `models.dataset.DocumentSegment.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5456:28
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5492:28
ERROR Argument `str | None` is not assignable to parameter `doc_id` with type `str` in function `_doc` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5497:28
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5533:28
ERROR Argument `str | None` is not assignable to parameter `doc_id` with type `str` in function `_doc` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5508:28
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5544:28
ERROR Argument `SimpleNamespace` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5547:17
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5583:17
ERROR Argument `None` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5568:45
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5604:45
ERROR Argument `SimpleNamespace` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5573:25
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5609:25
ERROR Argument `SimpleNamespace` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5582:25
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5618:25
ERROR Argument `SimpleNamespace` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5591:25
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5627:25
ERROR Argument `SimpleNamespace` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5606:17
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5642:17
ERROR Argument `SimpleNamespace` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5630:17
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5666:17
ERROR Argument `Literal['completed']` is not assignable to parameter `indexing_status` with type `IndexingStatus | SQLCoreOperations[IndexingStatus]` in function `models.dataset.Document.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5783:41
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:5819:41
ERROR Argument `str` is not assignable to parameter `metadata_filtering_mode` with type `Literal['automatic', 'disabled', 'manual']` in function `core.workflow.nodes.knowledge_retrieval.retrieval.KnowledgeRetrievalRequest.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:6090:33
+ --> tests/unit_tests/core/rag/retrieval/test_dataset_retrieval.py:6126:33
ERROR Argument `None` is not assignable to parameter `text` with type `str` in function `core.rag.splitter.text_splitter.RecursiveCharacterTextSplitter.split_text` [bad-argument-type]
--> tests/unit_tests/core/rag/splitter/test_text_splitter.py:1873:42
ERROR Argument `list[FromClause]` is not assignable to parameter `tables` with type `Sequence[Table] | None` in function `sqlalchemy.sql.schema.MetaData.create_all` [bad-argument-type]
|
Contributor
Pyrefly Type Coverage
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #44753 +/- ##
==========================================
- Coverage 89.40% 89.40% -0.01%
==========================================
Files 5986 5986
Lines 375154 375153 -1
Branches 76074 76074
==========================================
- Hits 335398 335397 -1
- Misses 33718 33719 +1
+ Partials 6038 6037 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
asukaminato0721
enabled auto-merge
October 26, 2026 03:48
asukaminato0721
approved these changes
Oct 26, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Fixes #<issue number>.Summary
Fixes #44752
Metadata filters with negative operators currently exclude documents that don't have the metadata key, because
NULL != 'Alice'evaluates to unknown andWHEREdrops the row. This PR makes those operators include such documents. Each of the four negative operators now addsOR <field> IS NULL. Range operators (<, >, ≤, ≥, before, after) and positive operators are unchanged. A missing value can't be placed above or below a number, so it shouldn't match range operators; only negations hold for a missing value.#43346 changes empty / not empty in the same function; this PR doesn't touch those branches.
Tests
Added a parametrized test backed by the unit-test SQLite database, using three documents:
alice{"writer": "Alice", "year": 2023}bob{"writer": "Bob", "year": 2025}missing{}The four negative-operator cases (
is not,≠,not contains,not in) fail before the fix and pass after it. The three control cases (is,in,>) pass both before and after, confirming positive and range operators are not affected.Behavior change
This changes retrieval results for existing apps that use these negative operators: documents without the metadata key will now be returned. If maintainers consider the current behavior intentional, feel free to close this PR.
Screenshots
is not "Alice"→{bob}is not "Alice"→{bob, missing}≠ 2023→{bob}≠ 2023→{bob, missing}not contains "Ali"→{bob}not contains "Ali"→{bob, missing}not in "Alice"→{bob}not in "Alice"→{bob, missing}is "Alice"→{alice}is "Alice"→{alice}in "Alice"→{alice}in "Alice"→{alice}> 2024→{bob}> 2024→{bob}Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint gods