Skip to content

fix(models): default HardwareUsage fields to 0 to tolerate partial server responses#1164

Open
s-zx wants to merge 1 commit intoqdrant:masterfrom
s-zx:fix/935-hardware-usage-optional-fields
Open

fix(models): default HardwareUsage fields to 0 to tolerate partial server responses#1164
s-zx wants to merge 1 commit intoqdrant:masterfrom
s-zx:fix/935-hardware-usage-optional-fields

Conversation

@s-zx
Copy link
Copy Markdown

@s-zx s-zx commented Mar 9, 2026

Problem

When QDRANT__SERVICE__HARDWARE_REPORTING=true is set and any API call is made (e.g. upsert), the server includes hardware usage statistics in the response. Because different qdrant server versions may not include all usage fields, the Python client raises a ValidationError:

qdrant_client.http.exceptions.ResponseHandlingException: 2 validation errors for ParsingModel[InlineResponse2006]
obj.usage.io_read
  Field required [type=missing, input_value={'cpu': 0, 'payload_io_re...vector_io_write': 16384}, input_type=dict]
obj.usage.io_write
  Field required [type=missing, input_value={'cpu': 0, 'payload_io_re...vector_io_write': 16384}, input_type=dict]

All seven fields in HardwareUsage were declared with Field(...) (required), so any server that omits even one field (e.g. an older server that doesn't yet report payload_index_io_read/payload_index_io_write, or a future server that adds new aggregate fields) causes a crash.

Fix

Change all HardwareUsage field declarations from Field(...) (required) to Field(default=0). These are unsigned hardware counters; 0 is the natural value when a counter is absent or not applicable. This makes the client robust to both older and newer server versions regardless of which subset of metrics the server reports.

Testing

from qdrant_client import QdrantClient
client = QdrantClient(url="http://localhost:6333")
# With QDRANT__SERVICE__HARDWARE_REPORTING=true, upsert/query should complete
# without ResponseHandlingException caused by missing HardwareUsage fields.

Closes #935

…rver responses

When QDRANT__SERVICE__HARDWARE_REPORTING=true is set, the server starts
returning hardware usage statistics in API responses.  Different qdrant
server versions may include different subsets of these counter fields
(e.g. payload_index_io_read / payload_index_io_write were added later).

Because all HardwareUsage fields were marked required (Field(...)),
any server that omits even one field triggers a Pydantic ValidationError:

  Field required [type=missing] for payload_index_io_read / io_read / …

Changing every field to Field(default=0) preserves semantics (these are
unsigned counters; 0 is the natural absent-value) while making the client
resilient to both older and newer server versions regardless of which
subset of metrics the server chooses to report.
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 9, 2026

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 89cf59b
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/69af4f74c6bbf900083ee730
😎 Deploy Preview https://deploy-preview-1164--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55f8040d-8117-48aa-afd8-2e4b6e1eea78

📥 Commits

Reviewing files that changed from the base of the PR and between e7101dc and 89cf59b.

📒 Files selected for processing (1)
  • qdrant_client/http/models/models.py

📝 Walkthrough

Walkthrough

This change modifies the HardwareUsage model in the Qdrant client's HTTP models to make previously required fields optional with zero defaults. Five fields—cpu, payload_io_read, payload_io_write, payload_index_io_read, and payload_index_io_write—are converted from required to defaulted to 0. Additionally, two new public fields, vector_io_read and vector_io_write, are introduced with the same default behavior. This aligns the client's model expectations with server responses when hardware reporting is enabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • fix: fix openapi usage structure #1053: Modifies the same HardwareUsage model in the OpenAPI definitions, replacing legacy field references and updating related field descriptions in the hardware usage tracking logic.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making HardwareUsage fields default to 0 to handle partial server responses.
Description check ✅ Passed The description is well-related to the changeset, explaining the problem, fix, and testing approach for the HardwareUsage fields issue.
Linked Issues check ✅ Passed The PR directly addresses issue #935 by making all HardwareUsage fields optional with default values of 0, allowing the client to handle servers that omit some fields.
Out of Scope Changes check ✅ Passed All changes are focused on the HardwareUsage model fields in response to issue #935; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@generall
Copy link
Copy Markdown
Member

generall commented Mar 9, 2026

This chage should be done in qdrant core, as proposed changes are targetting autogenerated code.

Also hardware reporting is an expetimental undocumented feature, not expected to be used in production

@s-zx
Copy link
Copy Markdown
Author

s-zx commented Mar 25, 2026

@generall Understood — makes sense to fix this in qdrant core since the client models are autogenerated. Happy to close this PR and open the issue upstream if that would be helpful, or defer to your team to handle it in the next codegen cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Qdrant client causes Pydantic validation error if QDRANT__SERVICE__HARDWARE_REPORTING=true is passed

2 participants