Skip to content
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

Merged
merged 3 commits into from
Aug 23, 2023

Conversation

sjaanus
Copy link
Contributor

@sjaanus sjaanus commented Aug 23, 2023

Restrict creation/update on strategies with invalid strategy type.

@vercel
Copy link

vercel bot commented Aug 23, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2023 1:45pm
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2023 1:45pm

@@ -14,6 +14,30 @@
"type": "string"
}
]
},
{
"name": "flexibleRollout",
Copy link
Contributor Author

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,
Copy link
Contributor Author

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validate for creation

@sjaanus sjaanus changed the title fix: do not allow creation/update of feature toggle with invalid stra… fix: do not allow creation/update of feature toggle with invalid strategy name Aug 23, 2023
strategyName: string | undefined,
): Promise<void> {
if (strategyName !== undefined) {
await this.strategyStore.get(strategyName);
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Contributor

@kwasniew kwasniew left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants