Skip to content

HttpContextFeatureFlagCache.GetCacheKey prevents evaluation of multiple distinct feature keys and property values #112

@0xfeeddeadbeef

Description

@0xfeeddeadbeef

Steps to reproduce

  1. Create a new feature flag with name test_feat_1 and condition test_prop equals "A"
  2. Create a new feature flag with name test_feat_2 and condition test_prop equals "A"
  3. Clone the repo: https://github.com/0xfeeddeadbeef/PostHogRepro.git
  4. Open the project and set your project API key on line 17 of Program.cs
  5. Run the project

Expected output

Feature: test_feat_1, User: test_user, Property: test_prop, IsEnabled: True
Feature: test_feat_1, User: test_user, Property: test_prop, IsEnabled: False
Feature: test_feat_2, User: test_user, Property: test_prop, IsEnabled: False
Feature: test_feat_2, User: test_user, Property: test_prop, IsEnabled: False

Actual output

Feature: test_feat_1, User: test_user, Property: test_prop, IsEnabled: True
Feature: test_feat_1, User: test_user, Property: test_prop, IsEnabled: True
Feature: test_feat_2, User: test_user, Property: test_prop, IsEnabled: True
Feature: test_feat_2, User: test_user, Property: test_prop, IsEnabled: True

Root cause

Looks like the HttpContextFeatureFlagCache.GetCacheKey method assumes that only one feature key (and with exactly the same property values) will ever be evaluated during a single ASP.NET Core HTTP request processing.

Workaround

Enable local evaluation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions