Skip to content

Fix "selected user is invalid" error when granting bundle to user with null name#388

Merged
simonhamp merged 1 commit into
mainfrom
fix-bundle-grant-user
May 19, 2026
Merged

Fix "selected user is invalid" error when granting bundle to user with null name#388
simonhamp merged 1 commit into
mainfrom
fix-bundle-grant-user

Conversation

@simonhamp
Copy link
Copy Markdown
Member

@simonhamp simonhamp commented May 19, 2026

Summary

When an admin tried to grant a plugin bundle to a user via the Filament Bundles table action, the form failed with The selected user is invalid for some users.

Filament's Select validates the chosen value by calling getOptionLabelUsing; if the callback returns a blank label, the implicit in rule rejects the value. The action's callback was returning User::find($value)?->name, which is null for users without a name set, so otherwise-valid users couldn't be selected.

Changes

  • Use getFilamentName() (which already falls back through display_namenameemail) in both the search results label and getOptionLabelUsing callback in app/Filament/Resources/PluginBundleResource.php, guaranteeing a non-blank label for any existing user.
  • Add a regression test covering a recipient with name = null.

Test plan

  • php artisan test --compact tests/Feature/Filament/GrantBundleToUserActionTest.php passes (2 tests, 13 assertions)
  • Manually grant a bundle to a user with name = null via the Filament admin

🤖 Generated with Claude Code

… name

Filament's Select uses getOptionLabelUsing to validate the chosen value;
returning a blank label causes the "in" rule to reject it. The bundle
grant action returned `User->name`, which is null for some users.

Use `getFilamentName()` so the label falls back through display_name,
name, then email, ensuring a non-blank result for any existing user.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@simonhamp simonhamp marked this pull request as ready for review May 19, 2026 16:43
@simonhamp simonhamp merged commit 4d5bb5a into main May 19, 2026
2 checks passed
@simonhamp simonhamp deleted the fix-bundle-grant-user branch May 19, 2026 16:47
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.

1 participant