Skip to content

bug(embeddings): GeminiEmbeddings awaits a synchronous google-genai call (TypeError at runtime) #926

Closed

Description

@AmitoVrito

Found while reviewing #923.

GeminiEmbeddings._embed_raw (src/synapsekit/embeddings/gemini.py) calls:

resp = await client.models.embed_content(model=self.model, contents=texts)

In the google-genai unified SDK, client.models.embed_content(...) is synchronous and returns an EmbedContentResponse directly. Awaiting it raises TypeError: object EmbedContentResponse can't be used in 'await' expression against the real API. The async surface is client.aio.models.embed_content(...) — every other Gemini path in the repo (e.g. llm/gemini.py) already uses the .aio/async variant.

The bug is currently masked by the provider test, which sets client.models.embed_content = AsyncMock(...) — making the sync method awaitable and hiding the defect (also a violation of the no-MagicMock testing rule).

Fix: use client.aio.models.embed_content(...); replace the mock-based test with a hand-written fake exposing a real async def aio.models.embed_content.

Activity

  1. added
    bug
    on Aug 12, 2026
  2. added a commit that references this issue on Aug 12, 2026
    e459fec
  3. AmitoVrito commented on Aug 12, 2026

    @AmitoVrito
    CollaboratorAuthor

    Fixed in #923 (commit e459fec) — switched to client.aio.models.embed_content and replaced the mock-based test with a hand-written async fake. CI green. Closing as the fix is committed and verified; it lands on main when #923 merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions