fix: qdrant_request empty body handling (use 'is not None' check)
Fix qdrant_request() to properly handle empty dict {} as body.
Python's 'if body' evaluates to False for empty dict, causing EOF error.
Changed:
- data = json.dumps(body).encode() if body is not None else None
Also cleaned up count_seeds() to use consistent body passing.
This commit is contained in:
@@ -41,7 +41,7 @@ BATCH_SIZE = int(os.environ.get("QDRANT_BATCH_SIZE", "100"))
|
|||||||
def qdrant_request(method: str, path: str, body: dict = None) -> dict:
|
def qdrant_request(method: str, path: str, body: dict = None) -> dict:
|
||||||
"""Make HTTP request to Qdrant"""
|
"""Make HTTP request to Qdrant"""
|
||||||
url = f"{QDRANT_URL}{path}"
|
url = f"{QDRANT_URL}{path}"
|
||||||
data = json.dumps(body).encode() if body else None
|
data = json.dumps(body).encode() if body is not None else None
|
||||||
req = urllib.request.Request(url, data=data, method=method)
|
req = urllib.request.Request(url, data=data, method=method)
|
||||||
req.add_header("Content-Type", "application/json")
|
req.add_header("Content-Type", "application/json")
|
||||||
req.add_header("Api-Key", QDRANT_API_KEY)
|
req.add_header("Api-Key", QDRANT_API_KEY)
|
||||||
@@ -605,7 +605,7 @@ def count_seeds(source: str = None) -> int:
|
|||||||
"""
|
"""
|
||||||
ensure_seeds_collection()
|
ensure_seeds_collection()
|
||||||
|
|
||||||
body = {} # Always pass empty body for count
|
body = {}
|
||||||
if source:
|
if source:
|
||||||
body["filter"] = {
|
body["filter"] = {
|
||||||
"must": [
|
"must": [
|
||||||
@@ -613,7 +613,7 @@ def count_seeds(source: str = None) -> int:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
result = qdrant_request("POST", f"/collections/{SEEDS_COLLECTION}/points/count", body if body else {})
|
result = qdrant_request("POST", f"/collections/{SEEDS_COLLECTION}/points/count", body)
|
||||||
return result.get("result", {}).get("count", 0)
|
return result.get("result", {}).get("count", 0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user