Skip to content

fix: replace ValueError/TypeError with InvalidArgumentError in core API#6590

Open
Sagargupta16 wants to merge 3 commits intochroma-core:mainfrom
Sagargupta16:fix/replace-valueerror-with-invalidargumenterror
Open

fix: replace ValueError/TypeError with InvalidArgumentError in core API#6590
Sagargupta16 wants to merge 3 commits intochroma-core:mainfrom
Sagargupta16:fix/replace-valueerror-with-invalidargumenterror

Conversation

@Sagargupta16
Copy link
Copy Markdown

Description

Replaces ValueError and TypeError raises with InvalidArgumentError in the core API validation layer, as requested in #3026.

Changes

File Replacements
chromadb/api/types.py 97
chromadb/api/models/CollectionCommon.py 13
chromadb/__init__.py 5
Total 115

These files handle user-facing input validation (IDs, metadata, embeddings, where clauses), making InvalidArgumentError the correct error type.

Why this matters

Callers catching ValueError currently can't distinguish Chroma validation errors from Python built-in errors. Using InvalidArgumentError gives callers a specific exception type to handle.

Re-opening — previous PR #6538 was closed when the fork was accidentally deleted during repo cleanup. Changes are identical.

Sagargupta16 and others added 2 commits March 4, 2026 08:05
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>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 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)

@propel-code-bot
Copy link
Copy Markdown
Contributor

propel-code-bot bot commented Mar 8, 2026

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

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.

No issues found; changes align exception handling consistently across validation paths.

Status: No Issues Found | Risk: Low

Review Details

📁 3 files reviewed | 💬 0 comments

Upstream added a new function using ValueError for #embedding key.
Kept InvalidArgumentError consistent with the rest of this PR's changes.
@Sagargupta16
Copy link
Copy Markdown
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.

@HammadB
Copy link
Copy Markdown
Collaborator

HammadB commented Mar 10, 2026

Thanks for the patch. We will take a look today !

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