Let FastMCPError propagate from dependencies#2646
Conversation
When a dependency raises ToolError or other FastMCPError subclasses, they were getting wrapped in RuntimeError with a generic "Failed to resolve dependency" message. This made it hard to use ToolError for validation in dependencies. Now FastMCPError subclasses propagate unchanged, matching the pattern used elsewhere in the codebase. Closes #2633 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughThe change modifies exception handling in the dependency resolution process to preserve FastMCPError exceptions and their subclasses (such as ToolError and ResourceError) instead of wrapping them as RuntimeError. Previously, all exceptions during dependency resolution were uniformly converted to RuntimeError with context information. Now, when a FastMCPError is raised during dependency resolution, it propagates unchanged. Other exception types continue to be wrapped as RuntimeError with the dependency resolution failure context, maintaining the previous error envelope behavior for non-FastMCP errors. Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)src/fastmcp/**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (3)📓 Common learnings📚 Learning: 2025-12-17T03:06:14.522ZApplied to files:
📚 Learning: 2025-12-17T03:06:14.522ZApplied to files:
🧬 Code graph analysis (1)src/fastmcp/server/dependencies.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (2)
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 |
Test Failure AnalysisSummary: The workflow failure was caused by a transient GitHub API timeout during the uv installation step, not by the code changes in this PR. Root Cause: The Suggested Solution: Simply re-run the failed workflow. This is a false negative caused by external infrastructure issues. No code changes are needed. Detailed AnalysisThe failure occurred in the "Run tests: Python 3.10 on ubuntu-latest" job during step 2 (Install uv): The workflow never reached the actual test execution phase. All other jobs in the same run succeeded:
Optional Future Improvement: Consider pinning a specific uv version in the workflow to avoid reliance on GitHub API calls during CI, making the workflow more resilient to API outages. Related Files
|
When a dependency raises ToolError or other FastMCPError subclasses, they
were getting wrapped in RuntimeError with a generic "Failed to resolve
dependency" message. This made it hard to use ToolError for validation
in dependencies.
Now FastMCPError subclasses propagate unchanged, matching the pattern
used elsewhere in the codebase.
Closes #2633
🤖 Generated with Claude Code