-
-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Steps to reproduce:
Create a file named bug.py with the following contents:
import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
import typesense
from typesense.exceptions import TypesenseClientError
client = typesense.Client({
'api_key': 'abcd',
'nodes': [{
'host': 'localhost',
'port': '8108',
'protocol': 'http'
}],
'connection_timeout_seconds': 2
})
try:
client.collections["test"].documents.import_([{"id":1}], batch_size=42)
except:
pass
try:
client.collections["test"].documents.import_([{"id":1}], import_parameters=dict(batch_size=42))
except:
passuv init
uv add typesense
uv run bug.py 2>&1 | grep 'HTTP Request'
Outputs:
INFO:httpx:HTTP Request: POST http://localhost:8108/collections/test/documents/import "HTTP/1.1 401 Unauthorized"
INFO:httpx:HTTP Request: POST http://localhost:8108/collections/test/documents/import?batch_size=42 "HTTP/1.1 401 Unauthorized"
Documentation recommends the right thing:
https://typesense.org/docs/30.1/api/documents.html#index-multiple-documents
But the Python signature contradicts:
https://github.com/typesense/typesense-python/blob/master/src/typesense/sync/documents.py#L226-L231
And if someone uses DocumentWriteParameters for import_parameters a type checker will complain that there is no batch_size in DocumentWriteParameters which is true for the type, but wrong run-time as this is the only way to pass in a batch_size that will be added to the request query string:
| class DocumentWriteParameters(DirtyValuesParameters): |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels