Skip to content

add validation for feature flag definition #14

Closed
@Eskibear

Description

@Eskibear

Feature flags are provided by IFeatureFlagProvider.

export interface IFeatureFlagProvider {
/**
* Get all feature flags.
*/
getFeatureFlags(): Promise<FeatureFlag[]>;
/**
* Get a feature flag by name.
* @param featureName The name of the feature flag.
*/
getFeatureFlag(featureName: string): Promise<FeatureFlag | undefined>;
}

We have two impl of feature flag providers for map-based and object-based usage. Data source can be arbitrary data but none of them validate whether a feature flag is valid according to the schema, which is not as robust as expected.

Two follow-up actions:

  • In our built-in IFeatureFlagProvider impl, add validation and throw errors when data source itself is invalid.
  • As customers can impl their own provider (potentially provide invalid data), in our impl of public APIs like isEnabled and getVariant, we can add validation after getting a feature flag from the provider, ensure we don't encounter unexpected error later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions