Skip to content

Go: add context, part7 - #17402

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
JinHai-CN:fix584
Jul 27, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
JinHai-CN:fix584

Conversation

@JinHai-CN

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Jin Hai <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

MCP 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.

Changes

MCP context-aware operations

Layer / File(s) Summary
Context-aware DAO operations
internal/dao/mcp.go
DAO methods accept explicit contexts and database handles, applying db.WithContext(ctx) to MCP queries and mutations.
Service context propagation
internal/service/mcp.go
CRUD, export, import, naming, and tool-discovery flows propagate contexts; validation messages and support types are updated.
Handler wiring and validation
internal/handler/mcp.go, internal/service/mcp_test.go
MCP endpoints pass request contexts to services, and import validation tests use the new signature.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: helios531

Poem

A rabbit hops with context in tow,
Through service paths where queries flow.
DAO ears listen, tools are found,
Imports bloom on safer ground.
“Hop-hop!” says Bun, “the trace is sound!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided, so the required Summary section is missing. Add a Summary section that briefly explains the PR goal and background context for reviewers.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: threading context through the Go MCP flow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN
JinHai-CN marked this pull request as ready for review July 27, 2026 03:12
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 27, 2026
@JinHai-CN JinHai-CN added the ci Continue Integration label Jul 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Preserve the incoming request context for import discovery.

Import discovery runs inside the request handler context; deriving FetchTools’ timeout from context.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

📥 Commits

Reviewing files that changed from the base of the PR and between 9d4847b and 64797ef.

📒 Files selected for processing (4)
  • internal/dao/mcp.go
  • internal/handler/mcp.go
  • internal/service/mcp.go
  • internal/service/mcp_test.go

@JinHai-CN
JinHai-CN merged commit 1571abd into infiniflow:main Jul 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant