Skip to content

fix: use bare raise instead of raise e to preserve traceback#403

Open
hobostay wants to merge 1 commit intobytedance:mainfrom
hobostay:fix/improper-exception-reraise
Open

fix: use bare raise instead of raise e to preserve traceback#403
hobostay wants to merge 1 commit intobytedance:mainfrom
hobostay:fix/improper-exception-reraise

Conversation

@hobostay
Copy link
Copy Markdown

Summary

  • Fix improper exception re-raising in mcp_client.py:71 that loses the original traceback

Problem

In MCPClient.connect_and_discover(), the exception handler:

except Exception as e:
    raise e

This discards the original traceback, making it harder to debug issues. In Python, raise e creates a new exception from the current location, while bare raise preserves the original traceback and exception chain.

Fix

Changed to bare raise to preserve the full exception context for debugging.

Test plan

  • Verify MCP connection errors still propagate correctly
  • Verify traceback now shows the original error location

🤖 Generated with Claude Code

In mcp_client.py, `except Exception as e: raise e` loses the original
traceback, making debugging harder. Use bare `raise` to preserve the
full exception chain.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Test User seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants