From f6456ee1c78283a3722f46558a1e3e7d2fb83087 Mon Sep 17 00:00:00 2001 From: Arpit Jain <3242828+arpitjain099@users.noreply.github.com> Date: Sun, 20 Oct 2024 14:15:26 +0900 Subject: [PATCH] Fix code scanning alert no. 24: Information exposure through an exception Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- End_to_end_Solutions/AOAISearchDemo/app/backend/app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/End_to_end_Solutions/AOAISearchDemo/app/backend/app.py b/End_to_end_Solutions/AOAISearchDemo/app/backend/app.py index fc2f168..f107e13 100644 --- a/End_to_end_Solutions/AOAISearchDemo/app/backend/app.py +++ b/End_to_end_Solutions/AOAISearchDemo/app/backend/app.py @@ -340,7 +340,7 @@ def chat(): return jsonify(response.to_item()), 400 except Exception as e: logger.exception(f"Exception in /chat: {e}", extra=properties) - response = ChatResponse(answer=Answer(), error=str(e), show_retry=True) + response = ChatResponse(answer=Answer(), error="An internal error has occurred.", show_retry=True) return jsonify(response.to_item()), 500 @@ -352,7 +352,7 @@ def get_all_user_profiles(): return jsonify(user_profiles_dict) except Exception as e: logger.exception(f"Exception in /user-profiles: {e}") - return jsonify({"error": "An internal error has occurred!"}), 500 + return jsonify({"error": "An internal error has occurred."}), 500 @app.route("/chat-sessions//", methods=["DELETE"]) @@ -369,7 +369,7 @@ def clear_chat_session(user_id: str, conversation_id: str): logger.exception( f"Exception in /chat-sessions//: {e}" ) - return jsonify({"error": "An internal error has occurred!"}), 500 + return jsonify({"error": "An internal error has occurred."}), 500 @app.route("/search-settings", methods=["GET"]) @@ -391,7 +391,7 @@ def get_search_settings(): return jsonify(search_settings.to_item()) except Exception as e: logger.exception(f"Exception in /search-settings: {e}") - return jsonify({"error": "An internal error has occurred!"}), 500 + return jsonify({"error": "An internal error has occurred."}), 500 if __name__ == "__main__":