improve(mcp): unwrap ExceptionGroups so real connection errors are visible#203
improve(mcp): unwrap ExceptionGroups so real connection errors are visible#203IsDon wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds a traceback import and a private ChangesException logging enhancement
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…sible
Errors raised inside streamable_http_client / sse_client / stdio_client get
wrapped in one or more ExceptionGroup layers by anyio's task-group
machinery. The _session_runner handler only logged '{exc}', which renders
as 'unhandled errors in a TaskGroup (1 sub-exception)' - the actual cause
is hidden behind the wrapper, sometimes through several nested layers.
Add a small _leaf_exceptions() helper that recursively descends
ExceptionGroup chains and returns the leaf-level error messages. Log them
explicitly in the warning, and emit the full traceback (also at WARNING
level so DEBUG logging doesn't need to be enabled) so anyone hitting an MCP
connection failure can see the real cause without attaching a debugger.
No behaviour change - purely a logging improvement; affects only the
failure path. I believe this is worthwhile given the nature of the project
for tinkering and MCP integration use-cases.
Changes:
- Add _leaf_exceptions(exc, depth, max_depth): recursively flattens
ExceptionGroup trees to "<Type>: <message>" leaf strings, depth-bounded.
- _session_runner logs the unwrapped leaves plus the full traceback at
WARNING.
- Docstring on _leaf_exceptions (Args/Returns + depth-cap behaviour).
- tests/test_mcp_error_visibility.py: flat exception, group flattening,
nested-group flattening, and the depth cap.
Merge note: if landing both MCP fixes, merge the streamable_http_client
auth fix (dnhkng#202, dnhkng#202) first. It
touches the same import block and _session_runner, so there is a small
overlap with this branch, but the two resolve manually without much
trouble - this change is best applied on top of dnhkng#202.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56f597a to
62f9528
Compare
|
@coderabbitai. check the branch conflict |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check the mergeable state of PR `#203`
gh pr view 203 --repo dnhkng/GLaDOS --json mergeable,mergeStateStatus,baseRefName,headRefName,title
# Also check if there are any conflicting files
gh pr view 203 --repo dnhkng/GLaDOS --json filesLength of output: 697
Here's a summary:
The PR touches To resolve, the contributor ( # Option 1: Rebase onto main (keeps history clean)
git fetch origin
git checkout improve/mcp-error-visibility
git rebase origin/main
# Resolve conflicts in src/glados/mcp/manager.py, then:
git rebase --continue
git push --force-with-lease origin improve/mcp-error-visibility
# Option 2: Merge main into the branch
git fetch origin
git checkout improve/mcp-error-visibility
git merge origin/main
# Resolve conflicts, then commit and pushThe conflict is isolated to |
|
@coderabbitai. Offer the fix for the merge conflict |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get the current main version of the conflicting file
echo "=== MAIN version ==="
git show origin/main:src/glados/mcp/manager.py
echo ""
echo "=== PR branch version ==="
git show origin/improve/mcp-error-visibility:src/glados/mcp/manager.pyLength of output: 23286 🏁 Script executed: #!/bin/bash
# Fetch the PR branch file content via GitHub API
gh api repos/dnhkng/GLaDOS/contents/src/glados/mcp/manager.py \
--jq '.content' \
-H "Accept: application/vnd.github.v3.raw" \
--raw-field ref=improve/mcp-error-visibility \
2>/dev/null || \
gh api "repos/dnhkng/GLaDOS/contents/src%2Fglados%2Fmcp%2Fmanager.py?ref=improve/mcp-error-visibility" \
--jq '.content' | base64 -dLength of output: 838 🏁 Script executed: #!/bin/bash
# Get the raw diff for PR `#203`
gh pr diff 203 --repo dnhkng/GLaDOSLength of output: 4606
Resolved patch for
|
|
@IsDon Can you check this? |
Usability Improvement for 3rd party integrations.
Errors raised inside streamablehttp_client / sse_client / stdio_client get wrapped in one or more ExceptionGroup layers by anyio's task group machinery. The session_runner exception handler only logs '{exc}', which renders as 'unhandled errors in a TaskGroup (1 sub-exception)' — the actual cause is hidden behind the wrapper, sometimes through multiple nested layers.
Add a small _leaf_exceptions() helper that recursively descends ExceptionGroup chains and returns the leaf-level error messages. Log them explicitly in the warning, and emit the full traceback (also at WARNING level so debug logging doesn't need to be enabled) so anyone hitting MCP connection failures can see the real cause without attaching a debugger.
No behaviour change — purely a logging improvement. Affects only the failure path.
Summary by CodeRabbit