diff --git a/CHANGELOG.md b/CHANGELOG.md index 81300f9a60..a2550adcc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.2.1 + +- fix: Variants should be allowed to be 'null' + ## 3.2.0 - feat: Add beta support for toggle variants diff --git a/lib/routes/admin-api/feature-schema.js b/lib/routes/admin-api/feature-schema.js index d3f445589b..262ccdcc69 100644 --- a/lib/routes/admin-api/feature-schema.js +++ b/lib/routes/admin-api/feature-schema.js @@ -50,7 +50,8 @@ const featureShema = joi .array() .unique((a, b) => a.name === b.name) .optional() - .items(variantsSchema), + .items(variantsSchema) + .allow(null), }) .options({ allowUnknown: false, stripUnknown: true }); diff --git a/lib/routes/admin-api/feature.test.js b/lib/routes/admin-api/feature.test.js index 31bc964958..28a497911d 100644 --- a/lib/routes/admin-api/feature.test.js +++ b/lib/routes/admin-api/feature.test.js @@ -100,6 +100,23 @@ test('should be allowed to use new toggle name', t => { .expect(201); }); +test('should be allowed to have variants="null"', t => { + t.plan(0); + const { request, base, perms } = getSetup(); + perms.withPermissions(CREATE_FEATURE); + + return request + .post(`${base}/api/admin/features`) + .send({ + name: 'new.name.null', + enabled: false, + strategies: [{ name: 'default' }], + variants: null, + }) + .set('Content-Type', 'application/json') + .expect(201); +}); + test('should not be allowed to reuse active toggle name', t => { t.plan(1); const { request, featureToggleStore, base } = getSetup();