Skip to content

Commit

Permalink
Fix code scanning alert no. 34: Information exposure through an excep…
Browse files Browse the repository at this point in the history
…tion

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 760c74a commit 59a4a6c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions End_to_end_Solutions/AOAISearchDemo/app/data/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,25 @@ def update_chat_session(user_id: str, conversation_id: str):
return Response(response=json.dumps(session.to_item()), status=200)
except (TypeError, NullValueError, MissingPropertyError, ValueError) as e:
logger.exception(f"update-chat-session: error: {e} ", extra=properties)
return Response(response=str(e), status=400)
return Response(response="An error occurred while processing your request.", status=400)
except SessionNotFoundError as e:
logger.exception(f"update-chat-session: error: {e} ", extra=properties)
return Response(response=str(e), status=404)
return Response(response="Chat session not found.", status=404)
except Exception as e:
logger.exception(f"update-chat-session: error: {e} ", extra=properties)
return Response(response=str(e), status=500)
return Response(response="An internal server error occurred.", status=500)

@app.route('/chat-sessions/<user_id>/<conversation_id>', methods=['DELETE'])
def clear_chat_session(user_id: str, conversation_id: str):
try:
chat_manager.clear_chat_session(user_id, conversation_id)
return Response(status=200)
except SessionNotFoundError as e:
return Response(response=str(e), status=404)
logger.exception(f"clear-chat-session: error: {e} ")
return Response(response="Chat session not found.", status=404)
except Exception as e:
return Response(response=str(e), status=500)
logger.exception(f"clear-chat-session: error: {e} ")
return Response(response="An internal server error occurred.", status=500)

@app.route('/user-profiles/<user_id>', methods=['POST'])
def create_user_profile(user_id: str):
Expand Down

0 comments on commit 59a4a6c

Please sign in to comment.