Skip to content

urllib.parse encoding of boolean values are incompatible with Meilisearch API #1044

@martinnj

Description

@martinnj

Description
Found this issue when writing a feature using the Index.get_documents method.
Basically the current behavior is that if there is no parameters or the filter is not provided, it uses the deprecated GET endpoint.
For converting the params dictionary to real URL params it uses urllib.parse.urlencode, which converts boolean values simply by passing them into str() so urllib.parse.urlencode({"key":True}) becomes key=True.

In my case I want to set {"retrieveVectors": True} which then results in the following error:

MeilisearchApiError. Error code: invalid_document_retrieve_vectors. Error message: Invalid value in parameter `retrieveVectors`: could not parse `True` as a boolean, expected either `true` or `false`. Hint: It might not be working because you're not up to date with the Meilisearch version that get_documents call requires. Error documentation: https://docs.meilisearch.com/errors#invalid_document_retrieve_vectors Error type: invalid_request

Expected behavior
That the documents are retrieved with the vectors.

Current behavior
The above error message.

Screenshots or Logs
If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

  • Python Version: 3.11.x
  • Meilisearch version: 1.10.(2|3)

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