Skip to content

Fix HTTP 500 errors in /ping endpoint#191

Open
plural-copilot[bot] wants to merge 1 commit into
mainfrom
agent/fix-ping-500-error-1778976355548
Open

Fix HTTP 500 errors in /ping endpoint#191
plural-copilot[bot] wants to merge 1 commit into
mainfrom
agent/fix-ping-500-error-1778976355548

Conversation

@plural-copilot
Copy link
Copy Markdown

Summary

This PR fixes the HTTP500Errors alert on demo-prod/flow-test/flow-test-stateless by removing the deliberate exception injection from the /ping health check endpoint.

Root Cause

The /ping endpoint in app/main.py contained a time-based conditional that raised an exception approximately 1/3 of the time:

if int(time.time()) % 3 == 0:
    raise Exception("unknown internal error")

This caused intermittent 500 Internal Server Error responses, matching the observed logs:

  • INFO: 127.0.0.1 ... "GET /ping HTTP/1.1" 500 Internal Server Error
  • Exception: unknown internal error

Changes

  1. app/main.py: Removed lines 15-16 (conditional exception logic)
  2. app/test_main.py: Added test_ping() to verify the endpoint returns 200 OK with {"pong": True}

Verification

✅ Docker build successful
✅ All tests passing:

  • test_read_root: PASSED
  • test_ping: PASSED (new)

Risk Assessment

Risk Level: Very Low

  • Simple, targeted fix removing error injection code
  • No breaking changes to API contract
  • Added test coverage ensures reliability
  • Health check now behaves as expected

Notes

Per the README, this endpoint was deliberately broken for testing AI-driven fixes. If this behavior should be preserved for demo purposes, consider using an environment variable or separate endpoint for fault injection testing.


🤖 Generated to resolve HTTP500Errors alert on flow-test-stateless

Remove conditional exception that caused intermittent 500 errors on the /ping health check endpoint. The endpoint was throwing 'Exception: unknown internal error' approximately 1/3 of the time when int(time.time()) % 3 == 0.

Changes:
- Removed conditional exception logic from /ping endpoint in app/main.py
- Added test coverage for /ping endpoint in app/test_main.py to verify 200 OK response
- All tests passing (test_read_root and test_ping)

This resolves the HTTP500Errors alert on demo-prod/flow-test/flow-test-stateless.
Copy link
Copy Markdown
Author

@plural-copilot plural-copilot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR was generated by the claude Plural Agent Runtime. Here's some useful information you might want to know to evaluate the ai's perfomance:

Name Details
💬 Prompt Investigate the app-code root cause for the firing HTTP500Errors alert on demo-prod/flow-test/flow-test-stateless and, if feasible, implement a fix as a pull request....
🔗 Run history View run history

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.

1 participant