Merge pull request #14389 from Budibase/fix/feature-flag-checks

Fix for feature flag issue
This commit is contained in:
Michael Drury 2024-08-15 17:21:45 +01:00 committed by GitHub
commit 20baecc9fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 550 additions and 154 deletions

View File

@ -159,8 +159,9 @@ export class FlagSet<V extends Flag<any>, T extends { [key: string]: V }> {
specificallySetFalse.add(feature)
}
// ignore unknown flags
if (!this.isFlagName(feature)) {
throw new Error(`Feature: ${feature} is not an allowed option`)
continue
}
if (typeof flagValues[feature] !== "boolean") {
@ -169,7 +170,7 @@ export class FlagSet<V extends Flag<any>, 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"
}
}

View File

@ -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",

@ -1 +1 @@
Subproject commit bc43c5230520d83f23afb14489aa9a2a92e7cd27
Subproject commit 14c89a5b20ee4de07723063458a2437b0dd4f2c9

693
yarn.lock

File diff suppressed because it is too large Load Diff