Skip to content

Commit

Permalink
corrected error in function param order, cleaned up logs
Browse files Browse the repository at this point in the history
  • Loading branch information
chantelle-cohere committed Aug 13, 2024
1 parent 2aef08f commit ea3e8e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/backend/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ async def delete_tool_auth(
"""

logger = ctx.get_logger()
logger.error(event=f"CHANTELLE TEST request body {request.body}")

def log_and_return_error(error_message: str):
logger.error(event=error_message)
Expand All @@ -351,10 +350,12 @@ def log_and_return_error(error_message: str):
)

user_id = ctx.get_user_id()
request_body = await request.json()
tool_id = request_body["tool_id"]

logger.error(event=f"CHANTELLE TEST tool_id {tool_id}, user_id {user_id}")
try:
request_body = await request.json()
tool_id = request_body["tool_id"]
except Exception as e:
log_and_return_error("Error parsing tool_id from request body.")

if user_id is None or user_id == "" or user_id == "default":
log_and_return_error("User ID not found.")
Expand All @@ -365,7 +366,7 @@ def log_and_return_error(error_message: str):
)

if tool_id != ToolName.Google_Drive:
log_and_return_error(f"Deletion for {tool_id} not implemented.")
log_and_return_error(f"Tool auth deletion for {tool_id} not implemented.")

tool = AVAILABLE_TOOLS.get(tool_id)

Expand All @@ -376,7 +377,6 @@ def log_and_return_error(error_message: str):

try:
tool_auth_service = tool.auth_implementation()
tool_auth_service.delete_tool_auth(session, user_id)
is_delete_tool_auth_successful = tool_auth_service.delete_tool_auth(
session, user_id
)
Expand Down
5 changes: 2 additions & 3 deletions src/backend/tools/google_drive/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ def get_token(self, session: DBSessionDep, user_id: str) -> str:
return tool_auth.access_token if tool_auth else None

def delete_tool_auth(self, session: DBSessionDep, user_id: str) -> bool:
logger.error(event=f"CHANTELLE TEST - GOOGLEDRIVEAUTH class - Deleting Tool Auth: {self.TOOL_ID} for user: {user_id}")
try:
tool_auth_crud.delete_tool_auth(session, self.TOOL_ID, user_id)
return true
tool_auth_crud.delete_tool_auth(session, user_id, self.TOOL_ID)
return True
except Exception as e:
logger.error(event=f"Error while deleting Tool Auth: {str(e)}")
return False

0 comments on commit ea3e8e2

Please sign in to comment.