fix(batch): set has_errors on per-object/reference errors in stream recv - #2115
Open
vaibzde wants to merge 1 commit into
Open
fix(batch): set has_errors on per-object/reference errors in stream recv#2115vaibzde wants to merge 1 commit into
vaibzde wants to merge 1 commit into
Conversation
In _BatchBaseSync/_BatchBaseAsync.__recv, each failed object or reference from the server was wrapped in a fresh BatchObjectReturn/BatchReferenceReturn with only `errors` set. has_errors defaults to False on the dataclass and __add__ only ORs it forward (`self.has_errors or other.has_errors`), so it never became True even though `errors` was non-empty. This meant `if result.has_errors:` never fired on data.ingest() (and on batch.stream(), though failed_objects/failed_references were populated correctly there since those are tracked separately). Fixes weaviate#2107
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
|
To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge. |
Author
|
I agree with the CLA. |
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.
Closes #2107.
What's broken
_BatchBaseSync.__recv(and the identical code in_BatchBaseAsync) builds a freshBatchObjectReturnfor each failed object coming back on the batch stream:has_errorsisn't passed, so it keeps its dataclass default ofFalse.BatchObjectReturn.__add__only ORs it forward (self.has_errors = self.has_errors or other.has_errors), so it never flips toTrueeven thougherrorshas an entry. Same thing for the reference-error branch (BatchReferenceReturn).This is the code both
data.ingest()andcollection.batch.stream()use, soresult.has_errorsstaysFalseon both, and the idiomaticif result.has_errors:check never fires.failed_objects/failed_referencesare still correct because those lists are populated separately in the same block, from the rawErrorObject/ErrorReference, not through the buggyhas_errorsaccumulation — that's why #2107's own repro sawfailed_objectscome back right onbatch.stream()while only checkinghas_errorsoningest().Fix
Pass
has_errors=Trueat the four call sites that construct these objects from a server-reported error (2 insync.py, 2 inasync_.py).How to verify
Added
test_ingest_has_errors_on_failed_objecttomock_tests/test_batch.py— a mock gRPCBatchStreamservice that returns one object error, driven throughcollection.data.ingest(), assertingresult.has_errors is True. It fails onmain(has_errorscomes backFalseeven thougherrorshas one entry) and passes with this fix.Ran locally (
uv venv --python 3.12 .venv,uv pip install -e . -r requirements-test.txt -r requirements-devel.txt):pytest mock_tests/— 52 passed (including the new test)pytest test/— 386 passed, 1 skippedruff format --check/ruff check— cleanflake8 --config=.flake8— cleanpyright(v1.1.400, matching.pre-commit-config.yaml) — 0 errorsI didn't run the integration suite (
integration/) since it needs a live Weaviate server — deferring to CI there.What I didn't touch
Left the actual server-side error paths, retry/backoff logic, and
failed_objects/failed_referencestracking alone — this is scoped to the one missing kwarg per call site.