Skip to content

fix: prevent exporting empty MCP server selection - #16589

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
euvre:euvre
Jul 3, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
euvre:euvre

Conversation

@euvre

@euvre euvre commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a bug in the MCP server batch management UI where clicking Export without selecting any MCP server would still call the backend and download an empty JSON file. Now, if no server is selected, a warning is shown and the export is aborted.

Changes

  • Guard against an empty array before calling .
  • Make the single-server parameter optional so the bulk-export call site () works without passing an argument.
  • Add the i18n key in both and .

Related issue

None.

Guard useExportMcp against empty id arrays, warn the user, and make
the single-server parameter optional so bulk export works correctly.
Add corresponding i18n keys for zh and en.
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 3, 2026
@euvre euvre added the ci Continue Integration label Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b238088c-422c-49a8-a136-7a9adda166ee

📥 Commits

Reviewing files that changed from the base of the PR and between 9182296 and 1ff0931.

📒 Files selected for processing (3)
  • web/src/locales/en.ts
  • web/src/locales/zh.ts
  • web/src/pages/user-setting/mcp/use-export-mcp.ts

📝 Walkthrough

Walkthrough

Adds an empty-selection guard to the MCP export hook that shows a localized warning instead of exporting, makes the mcp parameter optional, and derives the downloaded filename from mcp?.name with a 'mcp' fallback. New noServerSelected translation strings are added to English and Chinese locales.

Changes

MCP Export Guard

Layer / File(s) Summary
Export hook guard and filename logic
web/src/pages/user-setting/mcp/use-export-mcp.ts
useExportMcp now takes an optional mcp, warns via i18n and returns early when ids is empty, and downloads using a filename from mcp?.name (defaulting to 'mcp') instead of requiring mcp.
Localization strings
web/src/locales/en.ts, web/src/locales/zh.ts
Adds mcp.noServerSelected translation key ("Please select at least one MCP server" / Chinese equivalent) used by the new guard.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant useExportMcp
  participant i18n
  participant exportMcpServer

  User->>useExportMcp: trigger export(ids, mcp)
  alt ids is empty
    useExportMcp->>i18n: get mcp.noServerSelected
    useExportMcp-->>User: show warning message
  else ids provided
    useExportMcp->>exportMcpServer: exportMcpServer(ids)
    exportMcpServer-->>useExportMcp: data.code === 0
    useExportMcp-->>User: downloadJsonFile(mcp?.name or 'mcp')
  end
Loading

Possibly related PRs

  • infiniflow/ragflow#16564: Both PRs modify useExportMcp's export/download flow to derive the exported JSON filename from the current mcp instead of a fixed name.

Suggested reviewers: wangq8

Poem

A hop, a check, before we send,
"Pick a server, dear friend!"
No ids? We pause and say it clear,
In Chinese and English, loud and sincere.
Then download the file, named just right —
🐇 export complete, all snug and tight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: blocking export when no MCP server is selected.
Description check ✅ Passed The description includes the required Summary section and explains the bug fix and behavior change.
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.

@wangq8
wangq8 merged commit 7b34153 into infiniflow:main Jul 3, 2026
12 checks passed
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 3, 2026
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants