MOPS-608: Add InvalidEntityDataError for better entity validation errors#47
Conversation
Previously, invalid entity data in online feature requests would result in cryptic errors (AssertionError, ValueError, KeyError) that bubbled up as 500 Internal Server Errors. This change adds a dedicated exception type and raises it with helpful error messages for common issues: - Entity key doesn't exist in the project (EntityNotFoundException) - Entity key exists but doesn't match the feature view's required keys - Entity value has wrong type for the expected schema - Partial composite key provided (missing required entity keys) Changes: - errors.py: Add InvalidEntityDataError exception class - utils.py: Validate entity keys match feature view requirements - type_map.py: Wrap type assertions and value conversions with proper errors
There was a problem hiding this comment.
Pull request overview
Introduces InvalidEntityDataError exception to provide clear, actionable error messages when entity validation fails during online feature requests, replacing cryptic built-in exceptions like AssertionError and ValueError. This enables downstream services to properly handle validation failures and return appropriate 400-level HTTP status codes instead of 500s.
- Adds new
InvalidEntityDataErrorexception class for entity validation failures - Replaces assertions with explicit error checking in entity key matching and type conversion
- Provides descriptive error messages showing what was provided vs. what was expected
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| sdk/python/feast/errors.py | Defines new InvalidEntityDataError exception with documentation |
| sdk/python/feast/utils.py | Validates entity keys and raises InvalidEntityDataError when keys don't match or are missing |
| sdk/python/feast/type_map.py | Replaces assertions with explicit type checking and converts value conversion failures to InvalidEntityDataError |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
regarding the unit test failures, looks like they've been failing for a while: https://github.com/Ki-Insurance/feast/actions/runs/16492189884 not relevant to this change. would be a good idea to try and rebase against mainline soon and hopefully they will get fixed as part of that. |
InvalidEntityDataErrorexception for entity validation failures in online feature requestsn.b. there will be a follow up PR in feature-store-connector to take advantage of these which will allow the following improvements:
Example error messages