qdrant icon indicating copy to clipboard operation
qdrant copied to clipboard

collection_exists returns 404 due to wrong route instead of validating invalid names

Open woaiqjj opened this issue 1 month ago • 1 comments

Description

When calling collection_exists with invalid collection names (such as empty string or control characters), the client constructs an incorrect request path like:

/collections//exists

This leads the server to return:

404 Not Found
{"status":{"error":"Not found: Collection `exists` doesn't exist!"}}

This is not a genuine “not found” error, but a parameter validation issue. The request should have been rejected before reaching the REST route.


🔬 Reproduction Code

from qdrant_client import QdrantClient

client = QdrantClient(url="http://localhost:6333")

for name in ["", "\t", "\n"]:
    try:
        client.collection_exists(collection_name=name)
    except Exception as e:
        print(f"{repr(name)} -> {type(e).__name__}: {e}")

🧩 Current Behavior

  • The SDK/server generates /collections//exists for invalid names.
  • The server responds with 404 and message: "Collection \exists doesn't exist!"

✅ Expected Behavior

  • Invalid collection names (empty or control characters) should not reach the route handler.
  • SDK or server should validate input and return a clear error response:
    • HTTP 400 Bad Request, or
    • HTTP 422 Unprocessable Entity
  • The error message should explicitly state that the collection_name is invalid, rather than implying a missing "exists" collection.

💡 Suggested Fix

  • Option A (SDK level): Validate collection_name before sending the request and raise a ValueError if invalid.
  • Option B (Server level): Validate path parameters and return 400/422 with an appropriate error message ("Invalid collection name").

🧪 Environment

Component Version / Value
Qdrant v1.15.5
Python SDK qdrant-client==1.14.2
Endpoint http://localhost:6333

woaiqjj avatar Nov 08 '25 09:11 woaiqjj

I’ve opened a PR #7709 to fix this

chen0427ok avatar Dec 07 '25 07:12 chen0427ok