Add artisan commands for feature flag management#10
Open
stevethomas wants to merge 2 commits into
Open
Conversation
* Add artisan commands for managing feature flags Adds interactive `feature:manage` command for SSH-based flag toggling with table display, selection, and confirmation. Also adds scriptable `feature:on`, `feature:off`, and `feature:state` commands for automation. All commands delegate to existing FeatureFlags methods which handle cache invalidation and event dispatching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix code style Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Document artisan commands in README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| ); | ||
|
|
||
| if ($this->confirm("Set '{$selected}' to '{$newState}'?")) { | ||
| FeatureFlag::updateFeatureState($selected, FeatureState::from($newState)); |
There was a problem hiding this comment.
Bug: The ManageFeaturesCommand does not handle a potential MissingFeatureException, which can cause the artisan command to crash if a feature is not found during execution.
Severity: LOW
Suggested Fix
Wrap the call to FeatureFlag::updateFeatureState() at line 47 of ManageFeaturesCommand.php within a try-catch block. Catch the MissingFeatureException and output a user-friendly error message to the console, consistent with the error handling in other feature flag commands.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/Commands/ManageFeaturesCommand.php#L47
Potential issue: The `ManageFeaturesCommand` calls `FeatureFlag::updateFeatureState()`
without a `try-catch` block. If a feature is not found, `updateFeatureState()`
internally calls `getFeatureModel()`, which throws a `MissingFeatureException` by
default. This can occur in a race condition where a feature is deleted from the database
after the command has loaded the list of features but before the user selects one to
manage. Unlike other commands like `TurnOnFeatureCommand` which handle this exception,
`ManageFeaturesCommand` will crash with an unhandled exception instead of displaying a
graceful error message to the user running the command.
Did we get this right? 👍 / 👎 to inform future reviews.
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
Re-opened from #5. Originally merged but reverted from main to keep v1.x clean — this is targeted at v2.
feature:manage— interactive table to toggle feature statesfeature:on/feature:off— turn individual features on/offfeature:set— set a feature to a specific state (on/off/dynamic)Test plan
php artisan