Skip to content

fix(feature-management): enumerate flags without PersonalApiKey#250

Merged
turnipdabeets merged 1 commit into
PostHog:mainfrom
jojosenthusiast:fix/feature-enumeration-without-personal-api-key
Jul 2, 2026
Merged

fix(feature-management): enumerate flags without PersonalApiKey#250
turnipdabeets merged 1 commit into
PostHog:mainfrom
jojosenthusiast:fix/feature-enumeration-without-personal-api-key

Conversation

@jojosenthusiast

Copy link
Copy Markdown
Contributor

Fixes #64

Summary

  • Keeps local evaluation as the source when a PersonalApiKey is available.
  • Falls back to /flags with a stable sentinel distinct id for feature enumeration without a PersonalApiKey.
  • Adds unit coverage for both PostHogFeatureDefinitionProvider and PostHogVariantFeatureManager.

Verification

  • dotnet test tests/UnitTests.AspNetCore --filter FullyQualifiedName~Fallback -m:1
  • dotnet test tests/UnitTests.AspNetCore -m:1
  • git diff --check main...HEAD

Risk

Medium. This affects feature flag enumeration only; no public API changes are added.

@jojosenthusiast
jojosenthusiast requested a review from a team as a code owner June 29, 2026 14:18
@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(feature-management): enumerate flags..." | Re-trigger Greptile

@turnipdabeets

Copy link
Copy Markdown
Contributor

@jojosenthusiast thanks! LGTM, I think the reptile comment is worth addressing before merging #250 (comment). Mind giving that a look?

I think you'll also need to sign your commits to merge the PR.

@jojosenthusiast

jojosenthusiast commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

I looked at the Greptile bit, removed the duplicated test constants, and both tests now use the production sentinel directly. Re-ran the fallback tests and the AspNetCore unit tests locally, so this should be good to go now.

@jojosenthusiast
jojosenthusiast force-pushed the fix/feature-enumeration-without-personal-api-key branch from a268400 to b747837 Compare July 1, 2026 15:30
…piKey

Without a PersonalApiKey the local evaluator is null, which left
PostHogVariantFeatureManager.GetFeatureNamesAsync and
PostHogFeatureDefinitionProvider.GetAllFeatureDefinitionsAsync returning
nothing — breaking the MSFT Feature Management definition-driven path
for SDK consumers who use the remote /flags evaluation path only.

Fall back to a single /flags poll using a stable sentinel distinct_id
($feature_enumeration_sentinel) and use the returned flag keys. The
sentinel stays constant so the existing in-memory /flags cache (keyed
by distinct_id) reuses the response and PostHog does not spawn a new
phantom person per poll. Per-flag values for the sentinel are
discarded — only the key set is consumed. GetAllFeatureFlagsAsync does
not emit $feature_flag_called events, so no analytics noise.

Local evaluation behavior is unchanged when a PersonalApiKey exists.

Refs PostHog#64.
@jojosenthusiast
jojosenthusiast force-pushed the fix/feature-enumeration-without-personal-api-key branch from b747837 to 028701a Compare July 1, 2026 15:42
@turnipdabeets
turnipdabeets enabled auto-merge (squash) July 2, 2026 20:38
@turnipdabeets
turnipdabeets merged commit d59d8f3 into PostHog:main Jul 2, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Feature Management doesn't work with local evaluation

2 participants