Skip to content

Commit f700359

Browse files
authored
Merge pull request #15 from arpitjain099/alert-autofix-44
Fix code scanning alert no. 44: Information exposure through an exception
2 parents cca2f62 + 72888c1 commit f700359

File tree

1 file changed

+6
-3
lines changed
  • End_to_end_Solutions/AOAISearchDemo/app/data

1 file changed

+6
-3
lines changed

End_to_end_Solutions/AOAISearchDemo/app/data/app.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ def get_user_profile(user_id: str):
200200
else:
201201
return Response(response=json.dumps(user_profile.to_item()), status=200)
202202
except Exception as e:
203-
return Response(response=str(e), status=500)
203+
app.logger.error(f"Error in get_user_profile: {e}")
204+
return Response(response="An internal error has occurred.", status=500)
204205

205206
@app.route('/user-profiles', methods=['GET'])
206207
def get_all_user_profiles():
@@ -209,7 +210,8 @@ def get_all_user_profiles():
209210
json_user_profiles = [user_profile.to_item() for user_profile in user_profiles]
210211
return Response(response=json.dumps(json_user_profiles), status=200)
211212
except Exception as e:
212-
return Response(response=str(e), status=500)
213+
app.logger.error(f"Error in get_all_user_profiles: {e}")
214+
return Response(response="An internal error has occurred.", status=500)
213215

214216
@app.route('/user-groups/<group_id>', methods=['POST'])
215217
def create_user_group(group_id: str):
@@ -233,7 +235,8 @@ def create_user_group(group_id: str):
233235
except CosmosConflictError as e:
234236
return Response(response=str(e), status=409)
235237
except Exception as e:
236-
return Response(response=str(e), status=500)
238+
app.logger.error(f"Error in create_user_group: {e}")
239+
return Response(response="An internal error has occurred.", status=500)
237240

238241
@app.route('/user-groups/<group_id>', methods=['GET'])
239242
def get_user_group(group_id: str):

0 commit comments

Comments
 (0)