[Fix]: Raise NoResultFound Exception for Missing Base
Description
This PR addresses an issue in the backend where attempting to fetch a configuration with a non-existent base_id resulted in a non-descriptive error. The agenta.get_config function has been updated to raise a NoResultFound exception when the specified base does not exist, ensuring that error handling is more explicit and informative.
Related Issue
Closes AGE-702
Changes Included
- Updated db_manager
fetch_base_by_idfunction to raise aNoResultFoundexception if the providedbase_iddoes not match any existing base.
What to QA
- Test fetching a configuration with a valid
base_idto ensure it works as expected. - Test fetching a configuration with an invalid or non-existent
base_idand verify that theNoResultFoundexception is raised and logged correctly.
Acceptance Criteria
- [ ] The
NoResultFoundexception is raised when a non-existentbase_idis provided. - [ ] The correct exception message is logged, providing clear feedback for troubleshooting.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| agenta | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 21, 2024 10:01am |
| agenta-documentation | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 21, 2024 10:01am |
The function
fetch_base_by_idis called in a number of functions outside of try-except. This change might introduce unexpected bugs. Please make sure to add exception handling to wherever this function is used and make sure that the logic is not changed (for instance, please make sure that none of the places calling this function consider a None result as if there is no results).
Actually, no. The only function where fetch_base_by_id is called without a try-except block is the construct_app_container router, which has been updated. Every other function that calls fetch_base_by_id, in one way or another, is inside a try-except block.
Functions/routers that make use of the fetch_base_by_id function and have a try-except block include:
save_configrouterget_configrouterconstruct_app_container_urlrouter (this was the only place that did not have the function in a try-except block)add_variant_from_base_and_configrouterupdate_variant_imageandterminate_app_and_remove_app_variantfunctions, which are used in routers that have try-except blocks
re: @mmabrouk