fix(flags): handle empty evaluation key scopes - #258
Merged
Conversation
posthog-ruby Compliance ReportDate: 2026-08-25 11:02:12 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
marandaneto
marked this pull request as ready for review
August 25, 2026 11:06
Contributor
|
Reviews (1): Last reviewed commit: "fix(flags): handle empty evaluation key ..." | Re-trigger Greptile |
turnipdabeets
approved these changes
Aug 25, 2026
turnipdabeets
left a comment
Contributor
There was a problem hiding this comment.
Matches sdk-specs#47. flag_keys && flag_keys.empty? keeps nil unscoped, and asserting that the flag_missing event still fires is a good check that the empty snapshot stays usable rather than inert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
sdk-specs#47defines how SDKs should distinguish an empty feature flag evaluation scope from an omitted scope. The Ruby SDK previously treatedflag_keys: []like no scope and evaluated every available flag.This change makes the three cases explicit:
flag_keysis omitted ornil, evaluation remains unscoped and all available flags are evaluated.flag_keysis an empty array,evaluate_flagsreturns an empty snapshot without loading local flag definitions or calling/flags.flag_keyscontains keys, the existing scoped behavior remains unchanged and only those keys are requested and evaluated.The returned empty snapshot remains usable. Accessing a missing key returns the normal missing-flag result and records the normal access event.
💚 How did you test it?
BUNDLE_PATH=/tmp/posthog-ruby-bundle bundle exec rspec spec/posthog/feature_flag_evaluations_spec.rb- passed with 48 examples and 0 failures.BUNDLE_PATH=/tmp/posthog-ruby-bundle bundle exec rubocop- passed with 84 files inspected and no offenses.BUNDLE_PATH=/tmp/posthog-ruby-bundle bundle exec ruby -c lib/posthog/client.rb && BUNDLE_PATH=/tmp/posthog-ruby-bundle bundle exec ruby -c spec/posthog/feature_flag_evaluations_spec.rb- both syntax checks passed.BUNDLE_PATH=/tmp/posthog-ruby-bundle bundle exec rake public_api:check- passed.git diff --check origin/main...HEAD- passed.📝 Checklist
If releasing new changes
posthog-ruby.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Pi coding agent (
worker) prepared the existing implementation for review and opened this PR using the PR and autoreview skills. The local Pi session has no shareable URL. The agent added the required patch changeset, reran the Ruby validation, and reviewed the committed branch againstorigin/main. No review findings required code changes.