Skip to content

[BUG] EvaluationContext is not added with OpenFeatureBuilder #542

@kylejuliandev

Description

@kylejuliandev

Observed behavior

Calling OpenFeatureBuilder.AddContext() after you have added any providers causes the EvaluationContext to not be injected into the Api instance.

Expected Behavior

Calling OpenFeatureBuilder.AddContext() any place on the builder should add the EvaluationContext to the Api.

Steps to reproduce

Example code:

builder.Services.AddOpenFeature(featureBuilder =>
{
    featureBuilder
        .AddHostedFeatureLifecycle()
        .AddInMemoryProvider("InMemory", _ => new Dictionary<string, Flag>()
        {
            {
                "welcome-message", new Flag<bool>(
                    new Dictionary<string, bool> { { "show", true }, { "hide", false } }, "show")
            }
        })
        .AddContext(ctx => ctx.Set("region", "euw"));
});

Recording of the bug in action using a LoggingHook to read out the injected EvaluationContext.

no-evaluation-context-added.mp4

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions