Skip to content

fix: set original_uuid in ErrorObject when batch send raises exception - #1978

Open
rayensamali wants to merge 4 commits into
weaviate:mainfrom
rayensamali:fix/batch-error-missing-original-uuid
Open

fix: set original_uuid in ErrorObject when batch send raises exception#1978
rayensamali wants to merge 4 commits into
weaviate:mainfrom
rayensamali:fix/batch-error-missing-original-uuid

Conversation

@rayensamali

Copy link
Copy Markdown

Fixes #942

When an unexpected exception is raised during batch send, ErrorObject was
created without original_uuid, leaving it as None even when the source
object had a UUID. This fix passes original_uuid=obj.uuid in the exception
handler in base.py, consistent with how it is set in grpc_batch.py.
Added unit tests in test/collection/test_batch.py to verify original_uuid is preserved.

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

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.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

@rayensamali

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

g-despot and others added 3 commits September 11, 2026 10:13
# Conflicts:
#	test/collection/test_batch.py
Set the default in ErrorObject itself rather than at each call site.
original_uuid is derivable from object_.uuid at every producer, so a
__post_init__ default closes all of them at once: the client-side
batching exception path in base.py, plus the server-side batching paths
in sync.py and async_.py, which both returned None and are what
batch.stream() and data.ingest() use.

It also normalises the type. BatchObject.uuid is a str when the caller
supplied a UUID but a uuid.UUID when it was generated, so passing it
through unchanged made original_uuid's type depend on the failure mode.
str() at the single default makes it always a string, matching what
grpc_batch.py already produced.

Drop the two unit tests that constructed ErrorObject directly and
asserted the dataclass kept the kwarg they passed it; they pass with the
fix reverted. Assert on original_uuid in the three existing mock tests
that already drive the real batching paths instead.

Fixes weaviate#942

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sdBfKxiEgEUn1fnWgjYnk
@g-despot
g-despot requested review from g-despot and a balanced review from Copilot September 11, 2026 15:07

Copilot AI 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.

🟡 Changes recommended

Explicit UUID values are not normalized to strings despite the new API guarantee.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Ensures failed batch objects retain their submitted UUID across batching modes.

Changes:

  • Adds fallback UUID population to ErrorObject.
  • Adds timeout and streaming regression coverage.
  • Documents the corrected behavior.
File summaries
File Description
weaviate/collections/classes/batch.py Populates and documents original_uuid.
mock_tests/test_timeouts.py Tests timeout failures.
mock_tests/test_batch.py Tests streaming failures.
docs/changelog.rst Records the fix.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +192 to +194
def __post_init__(self) -> None:
if self.original_uuid is None:
self.original_uuid = str(self.object_.uuid)
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.

Return correct UUID for failed objects

5 participants