Skip to content

VectorStore.search(top_k=0) returns ALL documents #780

Closed

Description

@AmitoVrito

Location: src/synapsekit/retrieval/vectorstore.py:176-182

Problem: np.argpartition(scores, -0)[-0:] — -0 == 0, so [-0:] slices the whole array and top_k=0 returns every document sorted. Same in the filtered branch. Verified repro.

Fix: early-return [] when top_k <= 0.

Severity: Medium (correctness). Found in production-readiness audit.

Activity

  1. added
    bug
    on Jul 14, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions