Skip to content

fix: team settings crash — empty string in Select.Item value#78

Merged
TerrifiedBug merged 1 commit intomainfrom
fix/team-settings-select-empty-value
Mar 9, 2026
Merged

fix: team settings crash — empty string in Select.Item value#78
TerrifiedBug merged 1 commit intomainfrom
fix/team-settings-select-empty-value

Conversation

@TerrifiedBug
Copy link
Owner

Summary

  • Team settings page crashes with: A <Select.Item /> must have a value prop that is not an empty string
  • The Default Environment dropdown used value="" for the "None" option, which Radix UI Select forbids (empty string is reserved for clearing selection/showing placeholder)
  • Fix: use "__none__" sentinel value and convert to null at the mutation boundary

Test plan

  • Navigate to Team Settings as any admin — page should load without error
  • Default Environment dropdown should show "None" option and environment list
  • Selecting "None" should clear the default environment
  • Selecting an environment should set it as default

… string crash

Radix Select.Item forbids value="" — use "__none__" sentinel and convert at the boundary.
@github-actions github-actions bot added the fix label Mar 9, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 9, 2026

Greptile Summary

This PR fixes a crash on the Team Settings page caused by passing value="" to a Radix UI <Select.Item />, which forbids empty string values. The fix replaces the empty string with a "__none__" sentinel and correctly converts it back to null before calling the updateDefaultEnvironment tRPC mutation.

  • The server-side updateDefaultEnvironment procedure already has withTeamAccess("ADMIN") and withAudit("team.updated", "Team") middleware — no changes needed there.
  • The sentinel "__none__" cannot collide with real environment IDs since those are CUIDs.
  • The conversion logic value === "__none__" ? null : value is correctly placed at the mutation boundary, so null is what the backend receives and stores.
  • The server independently validates that any non-null defaultEnvironmentId exists in the DB and belongs to the team, providing an additional safety net.

No correctness or security issues found.

Confidence Score: 5/5

  • This PR is safe to merge — it's a minimal, targeted fix for a well-understood Radix UI constraint.
  • Single-file change with a straightforward sentinel pattern. The sentinel "__none__" is correctly converted to null before the mutation, the server validates all non-null environment IDs, and no security or auth logic is touched.
  • No files require special attention.

Important Files Changed

Filename Overview
src/app/(dashboard)/settings/_components/team-settings.tsx Replaces empty string value with "__none__" sentinel in the Default Environment Select component, and converts the sentinel back to null at the mutation boundary. Fix is correct, minimal, and well-scoped.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["team.defaultEnvironmentId\n(from DB)"] -->|null / undefined| B["Select value = '__none__'"]
    A -->|CUID string| C["Select value = CUID"]

    B --> D{User selects option}
    C --> D

    D -->|User picks 'None'| E["value = '__none__'"]
    D -->|User picks env| F["value = CUID"]

    E --> G["convert: '__none__' → null"]
    F --> H["pass through: CUID"]

    G --> I["updateDefaultEnvironment\n{ defaultEnvironmentId: null }"]
    H --> I

    I --> J{Server validation}
    J -->|null| K["Clear default — DB update"]
    J -->|CUID exists & belongs to team| L["Set default — DB update"]
    J -->|CUID not found or wrong team| M["TRPCError BAD_REQUEST"]
Loading

Last reviewed commit: a36f7ca

@TerrifiedBug TerrifiedBug merged commit 652ad5e into main Mar 9, 2026
12 checks passed
@TerrifiedBug TerrifiedBug deleted the fix/team-settings-select-empty-value branch March 9, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant