Skip to content

bug: query with empty filter returns empty results on local Milvus (syncIndexedCodebasesFromCloud) #279

@pablogravielseo

Description

@pablogravielseo

Problem

syncIndexedCodebasesFromCloud() in handlers.ts calls vectorDb.query() with an empty filter string to extract codebasePath from collection metadata:

const results = await vectorDb.query(
    collectionName,
    '', // Empty filter to get all results
    ['metadata'],
    1
);

This query returns empty results on local Milvus standalone, even when the collection has data. This was also reported by @juanmlarios in #246.

Root Cause

In milvus-vectordb.ts:435-437, the empty string is passed as filter:

const queryParams: any = {
    collection_name: collectionName,
    filter: filter,  // '' (empty string)
    output_fields: outputFields,
};

The Milvus Node SDK (@zilliz/milvus2-sdk-node) then processes this with:

data.expr = data.filter || data.expr || primaryKeyInIdsExpression;

Since '' is falsy in JavaScript, '' || data.expr falls through to data.expr (which is undefined), then to primaryKeyInIdsExpression (also undefined). The final expression sent to the Milvus gRPC server is effectively empty/undefined, which may return no results depending on the Milvus server version.

Impact

This bug prevents syncIndexedCodebasesFromCloud() from discovering codebases in Milvus, which causes:

  • cloudCodebases set remains empty
  • The sync removes all local codebases from the snapshot
  • search_code returns "not indexed" error

This is the underlying cause of #145 and the blocker that stalled #246.

Suggested Fix

Replace the empty filter with an expression that is always truthy and matches all documents. For example:

// Option A: use a non-empty expression that matches everything
const results = await vectorDb.query(
    collectionName,
    'id != ""',
    ['metadata'],
    1
);

Or fix at the milvus-vectordb.ts level to handle empty filter correctly:

// Option B: in milvus-vectordb.ts query(), use 'expr' key instead of 'filter'
const queryParams: any = {
    collection_name: collectionName,
    expr: filter || undefined,  // Let SDK handle the default
    output_fields: outputFields,
};

Related

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