fix(ui): extra_headers not persisting on MCP server edit#26003
Conversation
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 SummaryThis PR fixes Confidence Score: 5/5Safe 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 No files require special attention.
|
| 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)
Reviews (2): Last reviewed commit: "fix(ui): revert submit guard to allow in..." | Re-trigger Greptile
The ?.length guard prevented intentional clears from persisting — send the form value as-is since initialValues now populates it correctly.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@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! |
fc35c68
into
litellm_internal_staging
Summary
extra_headersexplicitly ininitialValuesmemo inmcp_server_edit.tsxinstead of relying on auseEffect→form.setFieldValuecall inMCPPermissionManagement.tsxthat races with Antd form initialization and silently failssetFieldValue("extra_headers", ...)fromMCPPermissionManagement.tsxundefinedinstead of[]when extra_headers is empty, so the backend'sexclude_nonedrops it rather than overwriting stored values with an empty arrayhard 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