Skip to content

[Bug]: REST API v2 entities/search accepts group_size=0 and -1 (gRPC rejects as "negative") #52309

Description

@yihui504

Is there an existing issue for this?

  • I have searched the existing issues

Environment

- Milvus version: v3.0.0 (release 2026-07-29, commit f46a0328558be155d11266a1a2b90602ccc9b366)
- Deployment mode: standalone (Docker, `milvusdb/milvus:v3.0.0`)
- MQ type: N/A
- SDK version: REST API v2 only (curl). pymilvus used for gRPC comparison.
- OS: Windows 11 (Docker Desktop)
- CPU/Memory: N/A
- GPU: None

Current Behavior

The REST API v2 POST /v2/vectordb/entities/search endpoint accepts groupSize=0 and groupSize=-1 in groupParams without validation (code: 0). The gRPC path correctly rejects both:

gRPC: code=1100, message="input group size:0 is negative, failed to do search_groupby"
gRPC: code=1100, message="input group size:-1 is negative, failed to do search_groupby"

The Grouping Search documentation states:

"By default, Grouping Search returns only one entity per group. If you want to increase the number of results to return per group, you can control this with the group_size and strict_group_size parameters."

This implies group_size is a positive integer that "increases" results per group — 0 and -1 are semantically meaningless.

Expected Behavior

groupSize should be validated as ≥ 1. REST should reject 0 and negative values with an explicit error, consistent with gRPC.

Steps To Reproduce

# 1. Create + load collection
curl -X POST http://localhost:19530/v2/vectordb/collections/create \
  -H "Content-Type: application/json" \
  -d '{"collectionName":"test_gs","dimension":4}'

# Insert data with "cat" field
for i in $(seq 0 9); do
  curl -X POST http://localhost:19530/v2/vectordb/entities/insert \
    -H "Content-Type: application/json" \
    -d "{\"collectionName\":\"test_gs\",\"data\":[{\"id\":$i,\"vector\":[0.$i,0.$i,0.$i,0.$i],\"cat\":$((i%3))}]}"
done

# 2. Search with groupSize=0 (bug)
curl -X POST http://localhost:19530/v2/vectordb/entities/search \
  -H "Content-Type: application/json" \
  -d '{"collectionName":"test_gs","data":[[0.5,0.5,0.5,0.5]],"limit":5,"groupParams":{"groupByField":"cat","groupSize":0}}'
# Response: {"code":0,...} — accepted (should be rejected)

# 3. Search with groupSize=-1 (bug)
curl -X POST http://localhost:19530/v2/vectordb/entities/search \
  -H "Content-Type: application/json" \
  -d '{"collectionName":"test_gs","data":[[0.5,0.5,0.5,0.5]],"limit":5,"groupParams":{"groupByField":"cat","groupSize":-1}}'
# Response: {"code":0,...} — accepted (should be rejected)

# 4. gRPC comparison
python -c "
from pymilvus import MilvusClient
mc = MilvusClient(uri='http://localhost:19530')
mc.search('test_gs', [[0.5]*4], limit=5, group_by_field='cat', group_size=0)
# → MilvusException: code=1100, 'input group size:0 is negative'
"

Milvus Log

REST v2 path (accepted - no error logged):

[2026/08/07 14:14:50.755 Z] [GIN] [/v2/vectordb/entities/search] [traceID=8eec52baf553ea87289e8c437d18ef92] [code=200] [latency=4.183428ms] [client=172.18.0.1] [method=POST] [error=]

Note the empty [error=] field - the REST path treats the invalid input as successful.

gRPC path (correctly rejected - pymilvus raises client-side):

<MilvusException: code=1100, message="input group size:0 is negative">

Run docker logs milvus-standalone for full logs.

Anything else?

  • Grouping Search docs: group_size controls "number of results to return per group" — implies positive integer
  • gRPC path validates at SearchGroupByOperator — REST v2 path skips this validation

Metadata

Metadata

Assignees

Labels

kind/bugIssues or changes related a bugtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions