Repository navigation
Go: add context, part7 - #17402
Go: add context, part7#17402
Conversation
Signed-off-by: Jin Hai <[email protected]>
📝 WalkthroughWalkthroughMCP request contexts now propagate from handlers through services into DAO queries and mutations. Service import and tool-discovery flows use context-aware operations, while related validation messages, exported errors, and test calls are updated. ChangesMCP context-aware operations
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/service/mcp.go (1)
630-637: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winPreserve the incoming request context for import discovery.
Import discovery runs inside the request handler context; deriving
FetchTools’ timeout fromcontext.Background()lets its discovery request outlive a cancelled import request until the fixed timeout.Proposed fix
- mcpCtx, cancel := context.WithTimeout(context.Background(), timeout) + mcpCtx, cancel := context.WithTimeout(ctx, timeout)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/service/mcp.go` around lines 630 - 637, Use the incoming request context instead of context.Background() when creating mcpCtx in the import discovery flow containing FetchTools, while retaining the timeout. Ensure cancellation of the request immediately propagates to FetchTools and does not allow discovery to outlive the import request.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@internal/service/mcp.go`:
- Around line 630-637: Use the incoming request context instead of
context.Background() when creating mcpCtx in the import discovery flow
containing FetchTools, while retaining the timeout. Ensure cancellation of the
request immediately propagates to FetchTools and does not allow discovery to
outlive the import request.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: de4a7cd0-d5df-4ff0-9ccf-d65691e17217
📒 Files selected for processing (4)
internal/dao/mcp.gointernal/handler/mcp.gointernal/service/mcp.gointernal/service/mcp_test.go
No description provided.