agenta icon indicating copy to clipboard operation
agenta copied to clipboard

[Fix]: Raise NoResultFound Exception for Missing Base

Open aybruhm opened this issue 1 year ago • 2 comments

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_id function to raise a NoResultFound exception if the provided base_id does not match any existing base.

What to QA

  • Test fetching a configuration with a valid base_id to ensure it works as expected.
  • Test fetching a configuration with an invalid or non-existent base_id and verify that the NoResultFound exception is raised and logged correctly.

Acceptance Criteria

  • [ ] The NoResultFound exception is raised when a non-existent base_id is provided.
  • [ ] The correct exception message is logged, providing clear feedback for troubleshooting.

aybruhm avatar Aug 29 '24 11:08 aybruhm

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

vercel[bot] avatar Aug 29 '24 11:08 vercel[bot]

The function fetch_base_by_id is 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_config router
  • get_config router
  • construct_app_container_url router (this was the only place that did not have the function in a try-except block)
  • add_variant_from_base_and_config router
  • update_variant_image and terminate_app_and_remove_app_variant functions, which are used in routers that have try-except blocks

re: @mmabrouk

aybruhm avatar Sep 10 '24 14:09 aybruhm