Skip to content

fix(ui): remove blank leading entry from access group model dropdown - #27521

Merged
oss-pr-review-agent-shin[bot] merged 1 commit into
BerriAI:shin_agent_oss_staging_05_09_2026from
Bytechoreographer:fix/empty_model
May 9, 2026
Merged

fix(ui): remove blank leading entry from access group model dropdown#27521
oss-pr-review-agent-shin[bot] merged 1 commit into
BerriAI:shin_agent_oss_staging_05_09_2026from
Bytechoreographer:fix/empty_model

Conversation

@Bytechoreographer

Copy link
Copy Markdown
Contributor

PR: fix(ui): blank leading entry in Models dropdown when creating an access group

Branch: Bytechoreographer:fix/empty_model
Target: BerriAI:litellm_internal_staging
PR link: https://github.com/Bytechoreographer/litellm/pull/new/fix/empty_model


Relevant issues

Pre-Submission checklist

  • npx vitest run src/components/ModelSelect/ModelSelect.test.tsx passes (13/13, including a new regression test)
  • Scope is isolated: 2 files changed, no new dependencies, no behavior change for callers that already pass includeSpecialOptions
  • Comment @greptileai and get Confidence Score ≥ 4/5 before requesting maintainer review

Type

🐛 Bug Fix

Changes

Root cause

img_v3_0211h_1b14bc5d-19ad-494d-b649-e3a6b2f6128g

On the Access Groups → Create modal, opening the Allowed Models dropdown
shows a blank/empty entry as the first item, above the actual model list.

AccessGroupBaseForm.tsx:81 renders the model picker as
<ModelSelect context="global" ... /> — without includeSpecialOptions. Inside
ModelSelect.tsx, the options array passed to antd's Select is built like
this:

options={[
  includeSpecialOptions ? { label: ..., options: [...] } : [],   // ← not spread
  ...(wildcard.length > 0 ? [{...}] : []),
  { label: <span>Models</span>, ... },
]}

The first element uses a ternary that returns [] when
includeSpecialOptions is falsy — but it is placed as a single element of the
outer array, not spread. So antd receives:

[ [], {Wildcard Options}, {Models} ]

antd Select walks each top-level element as an option group. The bare []
has no label / value, so it renders as an empty/blank leading row in the
popup. The two siblings below (Wildcard Options, Models) already use the
correct ...(cond ? [{...}] : []) spread pattern; only the Special Options
branch was inconsistent.

Reproduce:

  1. Navigate to Access Groups → click Create Access Group.
  2. Expand the Models section and click the Allowed Models dropdown.
  3. The first row in the popup is blank ✗; the model list begins on row 2.

Fix

Change the first branch to match the spread pattern already used by the other
two branches:

  options={[
-   includeSpecialOptions
-     ? { label: ..., title: "Special Options", options: [ ... ] }
-     : [],
+   ...(includeSpecialOptions
+     ? [
+       { label: ..., title: "Special Options", options: [ ... ] },
+     ]
+     : []),
    ...(wildcard.length > 0 ? [{ ... }] : []),
    { label: <span>Models</span>, title: "Models", options: regular.map(...) },
  ]}

Now the array contains only real groups. Empty branches contribute zero
elements instead of an empty array, so the leading blank row disappears.

No behavior change for callers that pass includeSpecialOptions={true}
(team / organization / user model pickers): before the fix the array was
[ {special}, {wildcard?}, {models} ], after the fix it is still
[ {special}, {wildcard?}, {models} ]. The bug only ever manifested when
includeSpecialOptions was falsy — which today is just the access-group
create/edit form (context="global" without the flag).

Tests

Added a regression test in ModelSelect.test.tsx that renders
<ModelSelect context="global" /> (the same way AccessGroupBaseForm calls
it) and asserts the rendered popup contains exactly two <optgroup>s
(Wildcard Options + Models), each with a non-empty label. Before the fix
this test produces three optgroups, the first with label=undefined
matching the visual blank-row symptom.

Files changed

File Change
ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx Switch the Special Options branch to the same ...(cond ? [{...}] : []) spread pattern used by Wildcard Options / Models, so a falsy includeSpecialOptions contributes zero elements instead of an empty array
ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.test.tsx Add regression test asserting no blank leading optgroup is rendered when includeSpecialOptions is omitted

The Allowed Models dropdown on the Access Groups create modal showed a
blank first row above the actual model list. The Special Options branch
of `ModelSelect`'s options array used a ternary that returned `[]` when
`includeSpecialOptions` was falsy, but the result was placed as a single
element of the outer array (not spread) — so antd's Select rendered the
empty array as a blank optgroup at the top. Switch to the same
`...(cond ? [{...}] : [])` spread pattern already used by the Wildcard
Options and Models branches.

No behavior change for callers that pass `includeSpecialOptions={true}`.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a blank leading row in antd's Select dropdown on the Access Groups → Create modal. The root cause was that the includeSpecialOptions branch returned a bare [] as an array element instead of spreading it, so antd received an empty array as a top-level "option group" and rendered it as a blank row.

  • ModelSelect.tsx: Switches the Special Options branch to ...(includeSpecialOptions ? [{…}] : []), matching the spread pattern already used by the Wildcard and Models branches. No behavior change for callers that pass includeSpecialOptions={true}.
  • ModelSelect.test.tsx: Adds a regression test that renders <ModelSelect context="global" /> and asserts exactly two optgroups (Wildcard Options + Models) appear, each with a non-empty label — covering the exact bug scenario.

Confidence Score: 5/5

Safe to merge — the change is a one-line structural fix confined to a single component with no impact on callers that already pass includeSpecialOptions={true}.

The fix is surgical: one spread operator change that eliminates the stray empty array element, leaving the rendered output identical for all existing callers. The regression test correctly targets the bug scenario and fails before the fix, passes after. No other files are touched and no new dependencies are introduced.

No files require special attention.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx Fixes the blank leading dropdown entry by spreading the Special Options branch — from includeSpecialOptions ? {…} : [] to ...(includeSpecialOptions ? [{…}] : []) — matching the existing wildcard/models pattern.
ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.test.tsx Adds a focused regression test that renders ModelSelect with context="global" (no includeSpecialOptions) and asserts exactly two optgroups appear with non-empty labels; test relies on document.querySelectorAll which queries the global DOM rather than the component's container.

Reviews (1): Last reviewed commit: "fix(ui): remove blank leading entry from..." | Re-trigger Greptile

@codecov

codecov Bot commented May 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Bytechoreographer

Copy link
Copy Markdown
Contributor Author

After
image

@oss-pr-review-agent-shin
oss-pr-review-agent-shin Bot changed the base branch from litellm_internal_staging to shin_agent_oss_staging_05_09_2026 May 9, 2026 20:30
@oss-pr-review-agent-shin
oss-pr-review-agent-shin Bot merged commit b799f94 into BerriAI:shin_agent_oss_staging_05_09_2026 May 9, 2026
42 checks passed
@oss-pr-review-agent-shin

Copy link
Copy Markdown
Contributor

🤖 litellm-agent: Squash-merged into staging branch shin_agent_oss_staging_05_09_2026. Staging PR: #27549


Triage Summary
Fixes a blank leading row in the Allowed Models dropdown on the Access Groups Create modal. The root cause was that the includeSpecialOptions branch in ModelSelect.tsx returned a bare [] as an array element instead of spreading it, causing antd Select to render an empty option group. The fix applies the same spread pattern already used by the Wildcard Options and Models branches. A regression test is added to ModelSelect.test.tsx asserting exactly two optgroups appear when includeSpecialOptions is omitted.

Merge Confidence: 5/5 ✅ READY
Ready to ship.

All checks green. Greptile 5/5, no blocking pattern findings, no CircleCI runs (OSS-typical).

fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…erriAI#27521)

Squash-merged by litellm-agent from Bytechoreographer's PR.
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