From b7f7632655c57ef1f33d6621bc446c12105c57e7 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Tue, 7 Jan 2025 18:32:18 +0000 Subject: [PATCH] action pr feedback Signed-off-by: Michael Beemer --- libs/shared/flagd-core/src/lib/feature-flag.ts | 2 ++ libs/shared/flagd-core/src/lib/flagd-core.spec.ts | 1 + libs/shared/flagd-core/src/lib/flagd-core.ts | 5 ++++- libs/shared/flagd-core/src/lib/parser.ts | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/shared/flagd-core/src/lib/feature-flag.ts b/libs/shared/flagd-core/src/lib/feature-flag.ts index 4cb1d13ac..b5c724c54 100644 --- a/libs/shared/flagd-core/src/lib/feature-flag.ts +++ b/libs/shared/flagd-core/src/lib/feature-flag.ts @@ -34,6 +34,8 @@ type RequiredResolutionDetails = Omit, 'value'> & { | { value: T; variant: string; + errorCode?: never; + errorMessage?: never; } ); diff --git a/libs/shared/flagd-core/src/lib/flagd-core.spec.ts b/libs/shared/flagd-core/src/lib/flagd-core.spec.ts index 09fa6adf2..5c4851ec3 100644 --- a/libs/shared/flagd-core/src/lib/flagd-core.spec.ts +++ b/libs/shared/flagd-core/src/lib/flagd-core.spec.ts @@ -355,6 +355,7 @@ describe('flagd-core error conditions', () => { }, logger, ); + /* eslint-disable @typescript-eslint/no-explicit-any */ (featureFlag as any)['_targeting'] = () => { throw new Error('something broke'); }; diff --git a/libs/shared/flagd-core/src/lib/flagd-core.ts b/libs/shared/flagd-core/src/lib/flagd-core.ts index 5ed78b71d..6f65fe203 100644 --- a/libs/shared/flagd-core/src/lib/flagd-core.ts +++ b/libs/shared/flagd-core/src/lib/flagd-core.ts @@ -182,7 +182,10 @@ export class FlagdCore implements Storage { const resolution = flag.evaluate(evalCtx, logger); - // Error during evaluation, returning default value + /** + * A resolution without a value represents an error condition. It contains + * information about the error but requires the default value set. + */ if (resolution.value === undefined) { return { ...resolution, diff --git a/libs/shared/flagd-core/src/lib/parser.ts b/libs/shared/flagd-core/src/lib/parser.ts index 2fb471b62..70e977140 100644 --- a/libs/shared/flagd-core/src/lib/parser.ts +++ b/libs/shared/flagd-core/src/lib/parser.ts @@ -56,6 +56,7 @@ export function parse(flagConfig: string, strictValidation: boolean, logger: Log flagsKey, { ...flag, + // Flag metadata has higher precedence than flag set metadata metadata: { ...parsedFlagConfig.metadata, ...flag.metadata,