From 008fd1b79d714d1f53f8444425ffc44e66f0e2dc Mon Sep 17 00:00:00 2001 From: "mw-middleware-labs-sandbox[bot]" <224139880+mw-middleware-labs-sandbox[bot]@users.noreply.github.com> Date: Mon, 13 Oct 2025 19:32:25 +0000 Subject: [PATCH] chore: Update user_profile function for safe user data retrieval and error handling --- flask/app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flask/app.py b/flask/app.py index c30b439..b2fac2f 100644 --- a/flask/app.py +++ b/flask/app.py @@ -60,9 +60,9 @@ def generate_exception(): @app.route('/user/') def user_profile(username): print(f"User profile requested for {username}") - test = user_data[username] + test = user_data.get(username) if not test: - raise + return jsonify({"error": "User not found"}) return jsonify({"message": f"Profile for {username}", "data": test}) @app.route('/process', methods=['POST']) @@ -154,4 +154,4 @@ def user_stats(username): }) if __name__ == '__main__': - app.run('0.0.0.0', 8010) + app.run('0.0.0.0', 8010) \ No newline at end of file