Skip to content

RetrievalQueryResponse rejects query results with null score #28

Description

@suguanYang

The SDK client.retrieval.query(...) can fail to parse valid API responses when retrieval results contain score: null.

Observed with knowhere-python-sdk==0.5.0 against staging after parsing a local markdown file and then calling:

query_result = client.retrieval.query(
    query="Which Knowhere SDK abilities does this document describe?",
    use_agentic=False,
)

The server response includes results like:

{
  "chunk_type": "text",
  "score": null,
  "content": "...",
  "source": {
    "source_file_name": "knowhere-demo-document.md",
    "document_id": "doc_...",
    "section_path": "Knowhere SDK Demo Document"
  }
}

The SDK raises a Pydantic validation error before returning the response:

ValidationError: results.0.score
  Input should be a valid number [type=float_type, input_value=None, input_type=NoneType]

Expected behavior: RetrievalResult.score should accept None if the API can return null, or the SDK should normalize null scores before model validation.

This blocks simple SDK demos that use the public client.retrieval.query(...) method because parsing works, but query crashes during response validation.

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