Skip to content

Conversation

agourlay
Copy link
Member

@agourlay agourlay commented May 13, 2025

This PR changes the behavior of the point upsert API so that is always overwrite the existing payload value.

Previously, passing a None payload left the existing payload unchanged.

The main motivation for this change is the bug #6449 where gRPC and REST would behave differently due to different handling of empty vs optional values.

Now passing an empty value or no value at all will always result in clearing the existing payload.

This changed passed the qdrant-client congruence tests.

@agourlay agourlay force-pushed the always-overwrite-existing-payload-on-upsert branch from dcff600 to d43b686 Compare May 13, 2025 15:25
Copy link
Contributor

coderabbitai bot commented May 14, 2025

📝 Walkthrough

Walkthrough

The updates introduce explicit handling for clearing a point's payload when an upsert operation is performed with a None or empty payload. In the core logic, if the payload is None, the existing payload is now cleared, rather than left unchanged. Documentation for the function was updated to reflect this behavior. Corresponding tests were added and extended in both shell and Python test suites to verify that upserting with an empty or omitted payload correctly clears the payload, and that subsequent upserts with non-empty payloads overwrite as expected. No public API signatures were changed.

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 718e842 and a915991.

📒 Files selected for processing (3)
  • lib/collection/src/collection_manager/segments_updater.rs (2 hunks)
  • tests/basic_grpc_test.sh (1 hunks)
  • tests/openapi/test_payload_operations.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/openapi/test_payload_operations.py (3)
tests/openapi/helpers/helpers.py (1)
  • request_with_validation (41-116)
tests/openapi/test_strictmode.py (1)
  • collection_name (9-12)
tests/openapi/conftest.py (1)
  • collection_name (50-51)
🔇 Additional comments (7)
lib/collection/src/collection_manager/segments_updater.rs (2)

402-403: Documentation update accurately reflects the new behavior.

The updated comment clearly explains the new behavior that when the payload is None, the existing payload will be cleared instead of being preserved.


419-421: Critical bug fix that ensures consistent behavior across APIs.

This change aligns with the PR objective to fix inconsistent payload handling between gRPC and REST APIs. Now when a None payload is provided during upsert, the existing payload will be explicitly cleared rather than preserved.

The implementation correctly calls segment.clear_payload() when payload is None, which aligns with the updated documentation and desired behavior. This change ensures consistent API behavior as described in issue #6449.

tests/basic_grpc_test.sh (1)

68-93: Good test case added to verify payload clearing behavior.

This test validates the core behavior change by:

  1. Upserting a point with an explicitly empty payload
  2. Retrieving the point and checking that the payload is cleared (null)
  3. Failing the test if any payload data is found

The test ensures that the gRPC API correctly implements the new payload clearing behavior when an empty payload is provided.

tests/openapi/test_payload_operations.py (4)

592-599: LGTM: Preparation for additional payload testing.

This section establishes the baseline state by retrieving the current payload for point ID 1 to verify later changes against.


600-626: Good test for empty payload dictionary clearing behavior.

This test validates that providing an empty payload dictionary ("payload": { }) via the PUT endpoint correctly clears the existing payload rather than preserving it. The test properly verifies the result by checking that the payload length is 0 after the operation.


627-658: Good test for payload overwriting behavior.

This test ensures that a non-empty payload provided during upsert correctly overwrites the existing payload. It properly verifies both the structure and content of the new payload after the operation.


659-683: Good test for omitted payload field behavior.

This test verifies that when the payload field is completely omitted from the request (not just empty), the existing payload is cleared. This is important to ensure consistency with the empty payload case.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@agourlay agourlay requested review from timvisee, generall and joein May 14, 2025 12:06
Copy link
Member

@joein joein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works in qdrant-client 👍

@agourlay agourlay merged commit db31bd2 into dev May 15, 2025
17 checks passed
@agourlay agourlay deleted the always-overwrite-existing-payload-on-upsert branch May 15, 2025 11:15
generall pushed a commit that referenced this pull request May 22, 2025
* Always overwrite existing payload on upsert

* Add REST tests
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.

Upsert a point with existing id with empty payload behaves differently with rest and grpc
3 participants