Fix LogicException on grant-to-user Select validation (#54)#394
Merged
Conversation
The searchable user_id selects on the plugin/product "Grant to User" actions defined getSearchResultsUsing() but not getOptionLabelUsing(), so Filament could not build the `in` validation rule and threw a LogicException on submit. Adds getOptionLabelUsing() to all three actions and covers the action submission path with tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #54 —
LogicException: Filament failed to validate the [mountedActions.0.data.user_id] field's selected options because it did not have an [options()] or [getOptionLabelUsing()] configuration.The "Grant to User" Filament actions use a searchable
Select::make('user_id')field that defined->getSearchResultsUsing()but not->getOptionLabelUsing(). On form submission Filament builds aninvalidation rule for the select and needs the valid option keys. A purely search-driven select has no static option set, so Filament falls back togetOptionLabelUsing()to validate the chosen value — and without it,Select::getInValidationRuleValues()throws theLogicException.The correct pattern already existed on
PluginBundleResource; three sibling grant actions were missing it.Changes
->getOptionLabelUsing(...)to theuser_idselect in:app/Filament/Resources/PluginResource.php(the action in the reported stack trace)app/Filament/Resources/PluginResource/Pages/EditPlugin.phpapp/Filament/Resources/ProductResource.phpuser_iddata (the existing tests only checked visibility, never the validation path):GrantPluginToUserActionTestGrantProductToUserActionTestLicensesRelationManagerselects use->relationship(), which supplies options automatically, so they were unaffected.Test plan
php artisan test --compact tests/Feature/Filament/GrantPluginToUserActionTest.php tests/Feature/Filament/GrantProductToUserActionTest.php tests/Feature/Filament/GrantBundleToUserActionTest.php— 9 passedLogicExceptionwhen the fix is revertedvendor/bin/pint --dirtyclean🤖 Generated with Claude Code