From 74f9b52f3409262125adda3cb1277314a77024c9 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 26 Aug 2026 09:44:20 +0200 Subject: [PATCH 1/2] fix(flags): align presence operator semantics --- .changeset/local-properties-align.md | 5 +++++ lib/posthog/feature_flags.rb | 3 +-- spec/posthog/feature_flag_spec.rb | 19 ++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .changeset/local-properties-align.md diff --git a/.changeset/local-properties-align.md b/.changeset/local-properties-align.md new file mode 100644 index 0000000..c815125 --- /dev/null +++ b/.changeset/local-properties-align.md @@ -0,0 +1,5 @@ +--- +"posthog-ruby": patch +--- + +Align local `is_set` and `is_not_set` evaluation with partial property context. diff --git a/lib/posthog/feature_flags.rb b/lib/posthog/feature_flags.rb index ef2a65e..7c6f12e 100644 --- a/lib/posthog/feature_flags.rb +++ b/lib/posthog/feature_flags.rb @@ -614,7 +614,6 @@ def self.semver_wildcard_bounds(value) def self.match_property(property, property_values, cohort_properties = {}) # only looks for matches where key exists in property_values - # doesn't support operator is_not_set PostHog::Utils.symbolize_keys! property PostHog::Utils.symbolize_keys! property_values @@ -629,7 +628,7 @@ def self.match_property(property, property_values, cohort_properties = {}) if !property_values.key?(key) raise InconclusiveMatchError, "Property #{key} not found in property_values" elsif operator == 'is_not_set' - raise InconclusiveMatchError, 'Operator is_not_set not supported' + return false end override_value = property_values[key] diff --git a/spec/posthog/feature_flag_spec.rb b/spec/posthog/feature_flag_spec.rb index ab7f9ec..5d965c9 100644 --- a/spec/posthog/feature_flag_spec.rb +++ b/spec/posthog/feature_flag_spec.rb @@ -1439,8 +1439,12 @@ module PostHog expect(FeatureFlagsPoller.match_property(property_a, { 'key' => 'value' })).to be true expect(FeatureFlagsPoller.match_property(property_a, { 'key' => 'value2' })).to be true - expect(FeatureFlagsPoller.match_property(property_a, { 'key' => '' })).to be true expect(FeatureFlagsPoller.match_property(property_a, { 'key' => nil })).to be true + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => false })).to be true + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => 0 })).to be true + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => '' })).to be true + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => [] })).to be true + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => {} })).to be true expect do FeatureFlagsPoller.match_property(property_a, { 'key2' => 'value' }) @@ -1448,6 +1452,19 @@ module PostHog expect { FeatureFlagsPoller.match_property(property_a, {}) }.to raise_error(InconclusiveMatchError) end + it 'with operator is_not_set' do + property_a = { 'key' => 'key', 'value' => 'is_not_set', 'operator' => 'is_not_set' } + + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => nil })).to be false + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => false })).to be false + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => 0 })).to be false + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => '' })).to be false + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => [] })).to be false + expect(FeatureFlagsPoller.match_property(property_a, { 'key' => {} })).to be false + + expect { FeatureFlagsPoller.match_property(property_a, {}) }.to raise_error(InconclusiveMatchError) + end + it 'with operator icontains' do property_a = { 'key' => 'key', 'value' => 'vaLuE', 'operator' => 'icontains' } From 39e05e1ab2d0c91ff07472017e4e6064bca70d84 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 26 Aug 2026 11:50:12 +0200 Subject: [PATCH 2/2] chore: include Rails in changeset --- .changeset/local-properties-align.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/local-properties-align.md b/.changeset/local-properties-align.md index c815125..0876bba 100644 --- a/.changeset/local-properties-align.md +++ b/.changeset/local-properties-align.md @@ -1,5 +1,6 @@ --- "posthog-ruby": patch +"posthog-rails": patch --- Align local `is_set` and `is_not_set` evaluation with partial property context.