Skip to content

fix: /thread_dump endpoint returns 500 due to faulthandler requiring real file descriptor#1428

Merged
EItanya merged 3 commits intomainfrom
iplay88keys/fix-thread-dump-endpoint
Mar 5, 2026
Merged

fix: /thread_dump endpoint returns 500 due to faulthandler requiring real file descriptor#1428
EItanya merged 3 commits intomainfrom
iplay88keys/fix-thread-dump-endpoint

Conversation

@iplay88keys
Copy link
Contributor

@iplay88keys iplay88keys commented Mar 4, 2026

Summary

  • Fix /thread_dump endpoint which returns 500 Internal Server Error because faulthandler.dump_traceback() requires a real OS file descriptor, but the code passes io.StringIO() which doesn't have one
  • Use tempfile.TemporaryFile(mode="w+") instead, and add all_threads=True to capture all thread stacks

Fixes #1426

Testing

Deployed to Kind cluster, confirmed curl http://localhost:8080/thread_dump returns thread stacks instead of 500

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Copilot AI review requested due to automatic review settings March 4, 2026 22:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the GET /thread_dump debugging endpoint in the kagent-adk FastAPI app so it no longer returns 500 due to faulthandler.dump_traceback() requiring a real OS file descriptor.

Changes:

  • Replace io.StringIO() with tempfile.TemporaryFile(mode="w+") for faulthandler.dump_traceback() output.
  • Enable all_threads=True to capture stack traces for all threads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
@EItanya EItanya merged commit 97a5014 into main Mar 5, 2026
23 checks passed
@EItanya EItanya deleted the iplay88keys/fix-thread-dump-endpoint branch March 5, 2026 02:49
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.

fix: /thread_dump endpoint returns 500 due to faulthandler requiring real file descriptor

3 participants