From c798c92c845a8f2b283540519347caed3211774b Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Tue, 24 Oct 2023 11:48:01 -0400 Subject: [PATCH] Ps/fix dev flags not defined (#6683) * Handle devFlags not defined * Default dev flags to false --- apps/web/config/development.json | 3 ++- libs/common/src/platform/misc/flags.spec.ts | 9 +++++++-- libs/common/src/platform/misc/flags.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/web/config/development.json b/apps/web/config/development.json index e3107f8788..62521c2f76 100644 --- a/apps/web/config/development.json +++ b/apps/web/config/development.json @@ -13,5 +13,6 @@ "secretsManager": true, "showPasswordless": true, "enableCipherKeyEncryption": false - } + }, + "devFlags": {} } diff --git a/libs/common/src/platform/misc/flags.spec.ts b/libs/common/src/platform/misc/flags.spec.ts index 2905be4e14..ed529b4abd 100644 --- a/libs/common/src/platform/misc/flags.spec.ts +++ b/libs/common/src/platform/misc/flags.spec.ts @@ -36,8 +36,13 @@ describe("devFlagEnabled", () => { process.env.ENV = "development"; }); - it("returns true by default", () => { - expect(devFlagEnabled("nonExistentFlag")).toBe(true); + it("returns false by default", () => { + expect(devFlagEnabled("nonExistentFlag")).toBe(false); + }); + + it("returns false if devFlags is not defined", () => { + delete process.env.DEV_FLAGS; + expect(devFlagEnabled("nonExistentFlag")).toBe(false); }); it("returns true if enabled", () => { diff --git a/libs/common/src/platform/misc/flags.ts b/libs/common/src/platform/misc/flags.ts index 7a8b5ca194..76c827376d 100644 --- a/libs/common/src/platform/misc/flags.ts +++ b/libs/common/src/platform/misc/flags.ts @@ -45,7 +45,7 @@ export function devFlagEnabled(flag: keyof DevF } const devFlags = getFlags(process.env.DEV_FLAGS); - return devFlags[flag] == null || !!devFlags[flag]; + return devFlags?.[flag] == null ? false : !!devFlags[flag]; } /**