Skip to content

Commit 214ebd7

Browse files
authored
Merge branch 'codeql' into alert-autofix-42
2 parents d3640fd + 2e19f99 commit 214ebd7

File tree

1 file changed

+8
-7
lines changed
  • End_to_end_Solutions/AOAISearchDemo/app/data

1 file changed

+8
-7
lines changed

End_to_end_Solutions/AOAISearchDemo/app/data/app.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ def get_user_profile(user_id: str):
205205
else:
206206
return Response(response=json.dumps(user_profile.to_item()), status=200)
207207
except Exception as e:
208-
logger.exception(f"get-user-profile: error: {e}")
209-
return Response(response="An internal server error occurred.", status=500)
208+
logging.error("An error occurred while fetching user profile: %s", e, exc_info=True)
209+
return Response(response="An internal error has occurred.", status=500)
210210

211211
@app.route('/user-profiles', methods=['GET'])
212212
def get_all_user_profiles():
@@ -215,8 +215,8 @@ def get_all_user_profiles():
215215
json_user_profiles = [user_profile.to_item() for user_profile in user_profiles]
216216
return Response(response=json.dumps(json_user_profiles), status=200)
217217
except Exception as e:
218-
logger.exception(f"get-all-user-profiles: error: {e}")
219-
return Response(response="An internal server error occurred.", status=500)
218+
logging.error("An error occurred while fetching all user profiles: %s", e, exc_info=True)
219+
return Response(response="An internal error has occurred.", status=500)
220220

221221
@app.route('/user-groups/<group_id>', methods=['POST'])
222222
def create_user_group(group_id: str):
@@ -240,8 +240,8 @@ def create_user_group(group_id: str):
240240
except CosmosConflictError as e:
241241
return Response(response=str(e), status=409)
242242
except Exception as e:
243-
logger.exception(f"create-user-group: error: {e}")
244-
return Response(response="An internal server error occurred.", status=500)
243+
logging.error("An error occurred while creating user group: %s", e, exc_info=True)
244+
return Response(response="An internal error has occurred.", status=500)
245245

246246
@app.route('/user-groups/<group_id>', methods=['GET'])
247247
def get_user_group(group_id: str):
@@ -284,7 +284,8 @@ def update_user_group(group_id: str):
284284
user_group = entities_manager.add_users_to_user_group(group_id, new_users)
285285
return Response(response=json.dumps(user_group.to_item()), status=200)
286286
except (TypeError, NullValueError, MissingPropertyError, ValueError) as e:
287-
return Response(response=str(e), status=400)
287+
logging.error("An error occurred while updating user group: %s", e, exc_info=True)
288+
return Response(response="An internal error has occurred.", status=400)
288289
except SessionNotFoundError as e:
289290
logging.error("Session not found: %s", e, exc_info=True)
290291
return Response(response="Session not found.", status=404)

0 commit comments

Comments
 (0)