-
-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not allow creation/update of feature toggle with invalid strategy name #4555
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -14,6 +14,30 @@ | |||
"type": "string" | |||
} | |||
] | |||
}, | |||
{ | |||
"name": "flexibleRollout", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add flexibleRollout for our e2e tests
@@ -225,24 +231,24 @@ class FeatureToggleService { | |||
|
|||
validateUpdatedProperties( | |||
{ featureName, projectId }: IFeatureContext, | |||
strategy: IFeatureStrategy, | |||
existingStrategy: IFeatureStrategy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactoring to make it more clear
this.validateUpdatedProperties(context, existingStrategy); | ||
await this.validateStrategyType(updates.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate for updating
@@ -502,6 +516,7 @@ class FeatureToggleService { | |||
const { featureName, projectId, environment } = context; | |||
await this.validateFeatureBelongsToProject(context); | |||
|
|||
await this.validateStrategyType(strategyConfig.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate for creation
strategyName: string | undefined, | ||
): Promise<void> { | ||
if (strategyName !== undefined) { | ||
await this.strategyStore.get(strategyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it depending on store throwing an error?
I'd rather call exists method on store and explicitly throw and error BadDataError. Those DB errors get propagated to the UI which is not nice. It's better to wrap it into some HTTP friendly error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment about verification of strategy
Restrict creation/update on strategies with invalid strategy type.