[Fix] Team UI: handle legacy dict shape for metadata.guardrails - #27224
Conversation
A team can have metadata.guardrails stored as {"modify_guardrails": bool}
(the permission-flag shape introduced in PR #4810) rather than the
expected string[]. The opt-out logic added in PR #25575 calls .filter()
on this field, which throws TypeError on a dict and crashes the team
detail page.
Add a safeGuardrailsList helper that returns [] when the field is not
an array, and route the three read sites through it.
Greptile SummaryGuards all six array-operation call sites in
Confidence Score: 5/5Narrow defensive UI fix; no logic changes, all affected call sites covered. The change is a targeted type-guard at every site that performs array operations on info.metadata.guardrails and info.metadata.opted_out_global_guardrails. All six call sites in the file have been updated, the save path remains unchanged and continues to write clean string[] values, and no other component reads these fields from the legacy shape. The risk surface is minimal. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/team/TeamInfo.tsx | Adds Array.isArray() guards at all 6 call sites that read info.metadata.guardrails or info.metadata.opted_out_global_guardrails, preventing a crash when legacy dict-shaped data is present |
Reviews (2): Last reviewed commit: "[Fix] Team UI: inline Array.isArray guar..." | Re-trigger Greptile
Replace the safeGuardrailsList helper with inline Array.isArray checks at each call site, and apply the same guard to opted_out_global_guardrails for consistency. No known legacy dict rows for opted_out_global_guardrails, but the unguarded `|| []` pattern is the same shape risk. Six call sites now defended directly: three for metadata.guardrails and three for metadata.opted_out_global_guardrails.
|
@greptileai re review |
1b25f85
into
litellm_internal_staging
…iAI#27224) * [Fix] Team UI: handle legacy dict shape for metadata.guardrails A team can have metadata.guardrails stored as {"modify_guardrails": bool} (the permission-flag shape introduced in PR BerriAI#4810) rather than the expected string[]. The opt-out logic added in PR BerriAI#25575 calls .filter() on this field, which throws TypeError on a dict and crashes the team detail page. Add a safeGuardrailsList helper that returns [] when the field is not an array, and route the three read sites through it. * [Fix] Team UI: inline Array.isArray guards for guardrails metadata Replace the safeGuardrailsList helper with inline Array.isArray checks at each call site, and apply the same guard to opted_out_global_guardrails for consistency. No known legacy dict rows for opted_out_global_guardrails, but the unguarded `|| []` pattern is the same shape risk. Six call sites now defended directly: three for metadata.guardrails and three for metadata.opted_out_global_guardrails.
Summary
Clicking into a team whose
metadata.guardrailsis stored as a dict (e.g.{"modify_guardrails": false}) instead of astring[]crashes the team detail page withTypeError: ((intermediate value) || []).filter is not a function.Adds inline
Array.isArray(...)guards at the six read sites inTeamInfo.tsxforinfo.metadata.guardrailsandinfo.metadata.opted_out_global_guardrails. Affected teams now load cleanly; saving the form heals the row. Root-cause follow-up tracked in LIT-31.Screenshots