From 06813fbe4afde299420d6d285fc4ee3b4d9a6dbd Mon Sep 17 00:00:00 2001
From: JeevaRamanathan <64531160+JeevaRamanathan@users.noreply.github.com>
Date: Fri, 4 Oct 2024 05:42:58 +0530
Subject: [PATCH] Enhanced error message in create, delete agent (#572)
Related to #568
Enhanced HTTPException in `create_agent.py` and `delete_agent.py`.
As this issue states, we aim to improve error messages throughout the
agents-api. I believe this issue can accommodate multiple pull requests.
Your suggestions are highly appreciated.
----
> [!IMPORTANT]
> Enhanced error messages in `create_agent.py` and `delete_agent.py` for
better clarity in `HTTPException` details.
>
> - **Error Messages**:
> - In `create_agent.py`, updated `HTTPException` detail to "Developer
not found. Please ensure the provided auth token (which refers to your
developer_id) is valid and the developer has the necessary permissions
to create an agent."
> - In `delete_agent.py`, updated `HTTPException` detail to "The
specified developer does not own the requested resource. Please verify
the ownership or check if the developer ID is correct."
>
> This description was created by [](https://www.ellipsis.dev?ref=julep-ai%2Fjulep&utm_source=github&utm_medium=referral)
for a085d4193ec0c36ba407f340c77e81834419dd69. It will automatically
update as commits are pushed.
Co-authored-by: Diwank Singh Tomer
---
agents-api/agents_api/models/agent/create_agent.py | 3 ++-
agents-api/agents_api/models/agent/delete_agent.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/agents-api/agents_api/models/agent/create_agent.py b/agents-api/agents_api/models/agent/create_agent.py
index 546d0d441..c1451bb30 100644
--- a/agents-api/agents_api/models/agent/create_agent.py
+++ b/agents-api/agents_api/models/agent/create_agent.py
@@ -30,7 +30,8 @@
lambda e: isinstance(e, QueryException)
and "asserted to return some results, but returned none"
in str(e): lambda *_: HTTPException(
- detail="developer not found", status_code=403
+ detail="Developer not found. Please ensure the provided auth token (which refers to your developer_id) is valid and the developer has the necessary permissions to create an agent.",
+ status_code=403
),
QueryException: partialclass(HTTPException, status_code=400, detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect."),
ValidationError: partialclass(HTTPException, status_code=400, detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format."),
diff --git a/agents-api/agents_api/models/agent/delete_agent.py b/agents-api/agents_api/models/agent/delete_agent.py
index cb6b16718..d8f710481 100644
--- a/agents-api/agents_api/models/agent/delete_agent.py
+++ b/agents-api/agents_api/models/agent/delete_agent.py
@@ -30,7 +30,8 @@
lambda e: isinstance(e, QueryException)
and "Developer does not own resource"
in e.resp["display"]: lambda *_: HTTPException(
- detail="developer not found or doesnt own resource", status_code=404
+ detail="The specified developer does not own the requested resource. Please verify the ownership or check if the developer ID is correct.",
+ status_code=404
),
QueryException: partialclass(HTTPException, status_code=400,detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect."),
ValidationError: partialclass(HTTPException, status_code=400,detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format."),