Skip to content

[ENH] Delete with limit in clients#6578

Merged
Sicheng-Pan merged 4 commits intomainfrom
03-06-_enh_delete_with_limit_in_clients
Mar 7, 2026
Merged

[ENH] Delete with limit in clients#6578
Sicheng-Pan merged 4 commits intomainfrom
03-06-_enh_delete_with_limit_in_clients

Conversation

@Sicheng-Pan
Copy link
Copy Markdown
Contributor

@Sicheng-Pan Sicheng-Pan commented Mar 7, 2026

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • N/A
  • New functionality
    • Introduce limit for delete in python and js client

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2026

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Copy Markdown
Contributor Author

Sicheng-Pan commented Mar 7, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Sicheng-Pan Sicheng-Pan marked this pull request as ready for review March 7, 2026 04:07
@propel-code-bot
Copy link
Copy Markdown
Contributor

propel-code-bot bot commented Mar 7, 2026

Add delete limit support and standardized delete responses across clients and APIs

This PR introduces a new limit parameter for delete operations across Python, JS, FastAPI, async APIs, and Rust bindings, and standardizes delete responses to return a DeleteResult with a deleted count instead of None. It also updates server request/response models and telemetry to reflect actual delete counts.

Additionally, the JS SDK and generated types are updated to align delete-collection response typing with a dedicated DeleteCollectionResponse, and Rust OpenAPI annotations are corrected to reference the appropriate delete response schema.

This summary was automatically generated by @propel-code-bot

propel-code-bot[bot]

This comment was marked as outdated.

@blacksmith-sh

This comment has been minimized.

@Sicheng-Pan Sicheng-Pan changed the base branch from 03-06-_enh_delete_with_limit to graphite-base/6578 March 7, 2026 05:31
@Sicheng-Pan Sicheng-Pan force-pushed the 03-06-_enh_delete_with_limit_in_clients branch from 2eeff23 to 94b54ba Compare March 7, 2026 05:31
@Sicheng-Pan Sicheng-Pan changed the base branch from graphite-base/6578 to main March 7, 2026 05:31
propel-code-bot[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@propel-code-bot propel-code-bot bot left a comment

Choose a reason for hiding this comment

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

One important logic concern about misleading delete counts was identified and needs adjustment.

Status: Changes Suggested | Risk: Medium

Issues Identified & Suggestions
  • Avoid defaulting deleted count to 0 when server returns none; use sentinel/warning: chromadb/api/fastapi.py
Review Details

📁 23 files reviewed | 💬 1 comments

👍 / 👎 individual comments to help improve reviews for you

json=body,
)
return None
return DeleteResult(deleted=resp.get("deleted", 0) if resp else 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

[Logic] When communicating with an older server that returns None (or empty JSON) for delete operations, this code defaults deleted to 0.

return DeleteResult(deleted=resp.get("deleted", 0) if resp else 0)

This is misleading because the operation might have successfully deleted thousands of records, but the client reports 0 deleted. Users relying on this return value for logic (e.g., if result['deleted'] > 0) will encounter bugs.

Consider verifying the server version or response structure and potentially returning a sentinel value (e.g., -1) or raising a warning if the count is unavailable, rather than silently returning a potentially incorrect zero.

Context for Agents
When communicating with an older server that returns `None` (or empty JSON) for delete operations, this code defaults `deleted` to `0`. 

```python
return DeleteResult(deleted=resp.get("deleted", 0) if resp else 0)
```

This is misleading because the operation might have successfully deleted thousands of records, but the client reports `0` deleted. Users relying on this return value for logic (e.g., `if result['deleted'] > 0`) will encounter bugs.

Consider verifying the server version or response structure and potentially returning a sentinel value (e.g., `-1`) or raising a warning if the count is unavailable, rather than silently returning a potentially incorrect zero.

File: chromadb/api/fastapi.py
Line: 567

@Sicheng-Pan Sicheng-Pan merged commit 91e0681 into main Mar 7, 2026
67 checks passed
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.

2 participants