Skip to content

[Fix] Team UI: handle legacy dict shape for metadata.guardrails - #27224

Merged
ryan-crabbe-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_fix-team-crashing
May 5, 2026
Merged

[Fix] Team UI: handle legacy dict shape for metadata.guardrails#27224
ryan-crabbe-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_fix-team-crashing

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Clicking into a team whose metadata.guardrails is stored as a dict (e.g. {"modify_guardrails": false}) instead of a string[] crashes the team detail page with TypeError: ((intermediate value) || []).filter is not a function.

Adds inline Array.isArray(...) guards at the six read sites in TeamInfo.tsx for info.metadata.guardrails and info.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

Screenshot 2026-05-05 at 1 39 11 PM Screenshot 2026-05-05 at 1 38 50 PM

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-apps

greptile-apps Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Guards all six array-operation call sites in TeamInfoView against a legacy dict stored in metadata.guardrails, replacing the broken || [] fallback with Array.isArray(...) checks. This prevents a TypeError crash when opening teams whose metadata.guardrails holds the {"modify_guardrails": false} shape written by the older backend path.

  • nonGlobalOptIns, optedOutGlobals, and both GuardrailSettingsView prop sites (inline and edit-modal variants) are now guarded — all 6 sites confirmed covered.
  • Saving the form writes back a valid string[], self-healing affected rows on next edit.

Confidence Score: 5/5

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

Important Files Changed

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

Comment thread ui/litellm-dashboard/src/components/team/TeamInfo.tsx Outdated
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.
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@ryan-crabbe-berri
ryan-crabbe-berri merged commit 1b25f85 into litellm_internal_staging May 5, 2026
114 of 115 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_fix-team-crashing branch May 5, 2026 22:40
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…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.
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.

2 participants