diff --git a/packages/backend-core/src/features/index.ts b/packages/backend-core/src/features/index.ts index 9c20c97826..e0bd29b1bc 100644 --- a/packages/backend-core/src/features/index.ts +++ b/packages/backend-core/src/features/index.ts @@ -160,7 +160,7 @@ export class FlagSet, T extends { [key: string]: V }> { } // ignore unknown flags - if (this.isFlagName(feature)) { + if (!this.isFlagName(feature)) { continue } @@ -170,7 +170,7 @@ export class FlagSet, T extends { [key: string]: V }> { // @ts-expect-error - TS does not like you writing into a generic type, // but we know that it's okay in this case because it's just an object. - flagValues[feature] = value + flagValues[feature as keyof FlagValues] = value tags[`flags.${feature}.source`] = "environment" } } diff --git a/packages/backend-core/src/features/tests/features.spec.ts b/packages/backend-core/src/features/tests/features.spec.ts index 553558ab14..5cd012f7a5 100644 --- a/packages/backend-core/src/features/tests/features.spec.ts +++ b/packages/backend-core/src/features/tests/features.spec.ts @@ -67,9 +67,9 @@ describe("feature flags", () => { expected: flags.defaults(), }, { - it: "should fail when an environment flag is not recognised", + it: "should ignore unknown feature flags", environmentFlags: "default:TEST_BOOLEAN,default:FOO", - errorMessage: "Feature: FOO is not an allowed option", + expected: { TEST_BOOLEAN: true }, }, { it: "should be able to read boolean flags from PostHog",