Skip to content

fix(ui): extra_headers not persisting on MCP server edit#26003

Merged
ryan-crabbe-berri merged 2 commits intolitellm_internal_stagingfrom
litellm_fix-extra-headers-not-persisting
Apr 18, 2026
Merged

fix(ui): extra_headers not persisting on MCP server edit#26003
ryan-crabbe-berri merged 2 commits intolitellm_internal_stagingfrom
litellm_fix-extra-headers-not-persisting

Conversation

@ryan-crabbe-berri
Copy link
Copy Markdown
Collaborator

@ryan-crabbe-berri ryan-crabbe-berri commented Apr 18, 2026

Summary

  • Set extra_headers explicitly in initialValues memo in mcp_server_edit.tsx instead of relying on a useEffectform.setFieldValue call in MCPPermissionManagement.tsx that races with Antd form initialization and silently fails
  • Removed the broken setFieldValue("extra_headers", ...) from MCPPermissionManagement.tsx
  • Changed submit payload to send undefined instead of [] when extra_headers is empty, so the backend's exclude_none drops it rather than overwriting stored values with an empty array

hard to repro because this initial bug is a race condition i think, but this should make it more defensive about keepign the correct values

Test plan

  • Edit an MCP server that has extra_headers set — verify they appear in the form
  • Submit the edit without changing extra_headers — verify they are preserved in the DB
  • Clear extra_headers and submit — verify they are removed
  • Create a new MCP server with extra_headers — verify they persist

Set extra_headers explicitly in initialValues instead of relying on
a useEffect setFieldValue call that races with Antd form initialization.
Also avoid sending empty array on submit so the backend's exclude_none
doesn't overwrite stored values.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 18, 2026

Greptile Summary

This PR fixes extra_headers not appearing when editing an MCP server by moving initialization from a racy useEffect/setFieldValue call in MCPPermissionManagement.tsx into the initialValues memo in mcp_server_edit.tsx. The approach is consistent with how static_headers is already handled and correctly ensures the form field is populated before Antd's first render.

Confidence Score: 5/5

Safe to merge — targeted two-line fix with no logic regressions.

Both changes are straightforward: moving extra_headers initialization into the memo (proven correct by the parallel static_headers pattern) and removing the redundant/racing setFieldValue. No P0 or P1 issues found. The submit payload's || [] fallback correctly handles the "user clears all headers" case.

No files require special attention.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx Adds `extra_headers: mcpServer.extra_headers
ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.tsx Removes the setFieldValue("extra_headers", ...) call from the useEffect that was racing with Antd form initialization; extra_headers is now handled via initialValues in the parent component.

Sequence Diagram

sequenceDiagram
    participant P as Parent (mcp_server_edit)
    participant F as Antd Form
    participant C as MCPPermissionManagement

    Note over P,C: Before this PR
    P->>F: mount with initialValues (no extra_headers)
    F-->>C: renders with empty extra_headers field
    C->>F: useEffect → setFieldValue("extra_headers", ...) [races, may arrive too late]
    Note over F: extra_headers field may remain empty

    Note over P,C: After this PR
    P->>F: mount with initialValues (includes extra_headers from mcpServer)
    F-->>C: renders with pre-populated extra_headers field
    Note over C: setFieldValue("extra_headers") call removed — no race
    C-->>F: static_headers/allow_all_keys still set via useEffect (unchanged)
Loading

Reviews (2): Last reviewed commit: "fix(ui): revert submit guard to allow in..." | Re-trigger Greptile

Comment thread ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx Outdated
The ?.length guard prevented intentional clears from persisting — send
the form value as-is since initialValues now populates it correctly.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@krrish-berri-2
Copy link
Copy Markdown
Contributor

@ryan-crabbe-berri — could you add a screenshot or short video showing that this change works as expected? It really helps reviewers verify the fix quickly. Thanks!

@ryan-crabbe-berri ryan-crabbe-berri merged commit fc35c68 into litellm_internal_staging Apr 18, 2026
97 of 99 checks passed
@ryan-crabbe-berri ryan-crabbe-berri deleted the litellm_fix-extra-headers-not-persisting branch April 18, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants