Skip to content

[OpsAI] fix: return 404 instead of raising KeyError in user_profile()#41

Open
mw-middleware-labs-sandbox[bot] wants to merge 1 commit into
masterfrom
OpsAI/fix-user-profile-keyerror-404
Open

[OpsAI] fix: return 404 instead of raising KeyError in user_profile()#41
mw-middleware-labs-sandbox[bot] wants to merge 1 commit into
masterfrom
OpsAI/fix-user-profile-keyerror-404

Conversation

@mw-middleware-labs-sandbox
Copy link
Copy Markdown

Problem

The user_profile() function raised an unhandled KeyError when an unknown username was requested, resulting in HTTP 500 responses and full stack trace heap retention per failed request — contributing to memory pressure and repeated OOMKills on the python-demo pod.

Fix

  • Replaced bare dict access with .get()
  • Returns a JSON 404 response for unknown users instead of raising an exception
  • Eliminates unhandled exception propagation through the Flask stack

Risk

Low — only the error path for non-existent users is affected. Happy path for existing users is unchanged.


This PR was automatically generated by OpsAI in response to an OOMKilled alert (rule_id: 1231002) on pod python-demo-6dbfd45d74-5hr7l.


OpsAI Context

Open OpsAI Chat: Open Chat

Created By

Name: Sanjay
Email: sanjay+sandbox@middleware.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants