Skip to content

Commit

Permalink
fix: Raise agent not found error on assertion failure (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
whiterabbit1983 authored Apr 16, 2024
1 parent 8b9d227 commit 594d186
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion agents-api/agents_api/routers/agents/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def update_agent(
detail="Agent not found",
)
except QueryException as e:
if e.code == "transact::assertion_failure":
if e.code in ("transact::assertion_failure", "eval::assert_some_failure"):
raise AgentNotFoundError(x_developer_id, agent_id)

raise
Expand Down
12 changes: 12 additions & 0 deletions agents-api/agents_api/routers/sessions/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ async def update_session(
status_code=status.HTTP_404_NOT_FOUND,
detail="Session not found",
)
except QueryException as e:
# the code is not so informative now, but it may be a good solution in the future
if e.code in ("transact::assertion_failure", "eval::assert_some_failure"):
raise SessionNotFoundError(x_developer_id, session_id)

raise


@router.patch("/sessions/{session_id}", tags=["sessions"])
Expand All @@ -186,6 +192,12 @@ async def patch_session(
status_code=status.HTTP_404_NOT_FOUND,
detail="Session not found",
)
except QueryException as e:
# the code is not so informative now, but it may be a good solution in the future
if e.code in ("transact::assertion_failure", "eval::assert_some_failure"):
raise SessionNotFoundError(x_developer_id, session_id)

raise


@router.get("/sessions/{session_id}/suggestions", tags=["sessions"])
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/routers/users/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def update_user(
)
except QueryException as e:
# the code is not so informative now, but it may be a good solution in the future
if e.code == "transact::assertion_failure":
if e.code in ("transact::assertion_failure", "eval::assert_some_failure"):
raise UserNotFoundError(x_developer_id, user_id)

raise
Expand Down

0 comments on commit 594d186

Please sign in to comment.