fix: replace ValueError/TypeError with InvalidArgumentError in core API#6590
Open
Sagargupta16 wants to merge 3 commits intochroma-core:mainfrom
Open
fix: replace ValueError/TypeError with InvalidArgumentError in core API#6590Sagargupta16 wants to merge 3 commits intochroma-core:mainfrom
Sagargupta16 wants to merge 3 commits intochroma-core:mainfrom
Conversation
Replace all ValueError and TypeError raises with InvalidArgumentError in the core API validation layer: - chromadb/api/types.py (97 replacements) - chromadb/api/models/CollectionCommon.py (13 replacements) - chromadb/__init__.py (5 replacements) This ensures consistent error types for invalid user input across the public API surface. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add missing InvalidArgumentError import to chromadb/__init__.py - Add missing InvalidArgumentError import to CollectionCommon.py - Update docstrings: ValueError -> InvalidArgumentError in Raises sections - Fix AsyncHttpClient error message referencing HttpClient - Fix grammar: "an list" -> "a list" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
Contributor
|
This also covers collection request validation paths and client initialization argument checks to keep invalid-input handling consistent across the core API. This summary was automatically generated by @propel-code-bot |
Upstream added a new function using ValueError for #embedding key. Kept InvalidArgumentError consistent with the rest of this PR's changes.
Author
|
@codetheweb @HammadB -- friendly ping. This PR has been open for a couple of days and is mergeable with no conflicts. Would appreciate a review when you get a chance. |
Collaborator
|
Thanks for the patch. We will take a look today ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replaces
ValueErrorandTypeErrorraises withInvalidArgumentErrorin the core API validation layer, as requested in #3026.Changes
chromadb/api/types.pychromadb/api/models/CollectionCommon.pychromadb/__init__.pyThese files handle user-facing input validation (IDs, metadata, embeddings, where clauses), making
InvalidArgumentErrorthe correct error type.Why this matters
Callers catching
ValueErrorcurrently can't distinguish Chroma validation errors from Python built-in errors. UsingInvalidArgumentErrorgives callers a specific exception type to handle.