Skip to content

Conversation

@GunaPalanivel
Copy link
Contributor

Related Issues

Proposed Changes

This PR fixes the Google GenAI Document Embedder to not modify input Documents in place when setting embeddings.

Changes Made

GoogleGenAIDocumentEmbedder:

  • run() method: Use replace(doc, embedding=embeddings) instead of doc.embedding = embeddings
  • run_async() method: Use replace(doc, embedding=embeddings) instead of doc.embedding = embeddings

Tests Added

  • test_run_does_not_modify_original_documents for document embedder
  • test_run_async_does_not_modify_original_documents for document embedder

How did you test it?

cd integrations/google_genai
hatch run test:unit  # All 48 tests pass
hatch run fmt-check  # All checks pass

Notes for the reviewer

This follows the established pattern from:

…uments

This PR fixes the Google GenAI document embedder to not modify input
Documents in place when setting embeddings.

Instead of mutating the original documents:
  doc.embedding = embeddings

We now create new document instances using dataclass replace:
  replace(doc, embedding=embeddings)

This follows the established pattern from haystack-ai/haystack#9693 and
aligns with other integrations (FastEmbed, Optimum, Nvidia, Bedrock, Cohere).

Related to: deepset-ai#2174
@GunaPalanivel GunaPalanivel requested a review from a team as a code owner January 17, 2026 05:24
@GunaPalanivel GunaPalanivel requested review from davidsbatista and removed request for a team January 17, 2026 05:24
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.

1 participant