Skip to content

async Collection.exists() still swallows all exceptions (PR #1950 fixed sync path only, async regression remains) #2100

Closed

Description

@tsushanth

Bug

async_collection.exists() in weaviate/collections/collection/async_.py catches all exceptions and returns False, making it impossible to distinguish "collection not found" from "connection error / auth failure / timeout":

async def exists(self) -> bool:
    try:
        await self.config.get(simple=True)
        return True
    except Exception:      # ← catches everything
        return False

Why this matters

A caller doing:

if not await collection.exists():
    await client.collections.create(...)

will silently try to create a collection every time the server is unreachable — which may succeed with wrong configuration, fail with a confusing error, or mask a network outage entirely.

Incomplete fix from PR #1950

Issue #1799 reported this exact problem. PR #1950 (merged Feb 2026) fixed the synchronous path in weaviate/collections/collection/sync.py:

# sync.py — correctly re-raises on non-404
except UnexpectedStatusCodeError as e:
    if e.status_code == 404:
        return False
    raise

But the async counterpart in async_.py was never updated and still has the bare except Exception: return False. A collaborator noted on the closed issue: "Pretty sure this was not fixed!" — and indeed it was not for the async client.

Suggested fix

Mirror the sync implementation exactly:

async def exists(self) -> bool:
    try:
        await self.config.get(simple=True)
        return True
    except UnexpectedStatusCodeError as e:
        if e.status_code == 404:
            return False
        raise

References

Activity

  1. adityaanikam commented on Jul 23, 2026

    @adityaanikam

    I'd like to work on this. Looking at the code, sync.py's exists() (lines 201-209) already handles this correctly by catching UnexpectedStatusCodeError and only swallowing 404s — I'll mirror that exact pattern into async_.py's exists(). I also noticed there's no existing test coverage for exists() on either the sync or async path, which is likely how the async gap in #1950 went unnoticed — I'll add tests for both to close that gap. Will open a PR referencing this issue once it's ready.

  2. added a commit that references this issue on Jul 30, 2026
    0275bd8
  3. added a commit that references this issue on Aug 10, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions