From 8a8a7b0899d93894c9fea3da95b5a92559262e1b Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Tue, 5 Sep 2023 11:09:55 +0200 Subject: [PATCH] 1-1329: return 400 when pattern is empty but example is not (#4609) Adding an example when there is no pattern doesn't make any sense, so it should be an error. Tests in https://github.com/ivarconr/unleash-enterprise/pull/721 --- src/lib/services/project-service.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/services/project-service.ts b/src/lib/services/project-service.ts index 8ac9b5531478..84a7b97fabe7 100644 --- a/src/lib/services/project-service.ts +++ b/src/lib/services/project-service.ts @@ -180,6 +180,12 @@ export default class ProjectService { `You've provided a feature flag naming example ("${example}") that doesn't match your feature flag naming pattern ("${pattern}"). Please provide an example that matches your supplied pattern.`, ); } + + if (!pattern && example) { + throw new BadDataError( + "You've provided a feature flag naming example, but no feature flag naming pattern. You must specify a pattern to use an example.", + ); + } } };