Skip to content

fix: replace ValueError/TypeError with InvalidArgumentError in API layer#6832

Open
Pawansingh3889 wants to merge 1 commit intochroma-core:mainfrom
Pawansingh3889:fix/replace-valueerror-with-invalidargumenterror
Open

fix: replace ValueError/TypeError with InvalidArgumentError in API layer#6832
Pawansingh3889 wants to merge 1 commit intochroma-core:mainfrom
Pawansingh3889:fix/replace-valueerror-with-invalidargumenterror

Conversation

@Pawansingh3889
Copy link
Copy Markdown

Replaces 103 user-facing ValueError/TypeError with InvalidArgumentError in the API layer (types.py, client.py, async_client.py) for consistent error handling.

Replaces user-facing validation errors with ChromaDB's own
InvalidArgumentError for consistent error handling across the API.

Files changed:
- chromadb/api/types.py: 95 ValueError + 2 TypeError → InvalidArgumentError
- chromadb/api/client.py: 5 ValueError → InvalidArgumentError
- chromadb/api/async_client.py: 3 ValueError → InvalidArgumentError

Closes chroma-core#3026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 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

Standardize API Argument Validation Errors to InvalidArgumentError

This PR replaces user-facing ValueError and TypeError raises with InvalidArgumentError across the API layer for consistent exception semantics. The changes are concentrated in validation-heavy paths in chromadb/api/types.py, plus connection/tenant-database validation paths in both chromadb/api/client.py and chromadb/api/async_client.py.

The update appears mechanical and behavior-preserving in terms of validation logic and error messages, while changing the exception class surfaced to callers. This improves error handling consistency for SDK and API consumers that rely on Chroma-specific error types.

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 were found; the exception normalization changes appear consistent, mechanical, and low risk.

Status: No Issues Found | Risk: Low

Review Details

📁 3 files reviewed | 💬 0 comments

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.

1 participant