feat(posthog-server): support starts_with/ends_with local flag operators - #691
Open
dustinbyrne wants to merge 2 commits into
Open
feat(posthog-server): support starts_with/ends_with local flag operators#691dustinbyrne wants to merge 2 commits into
dustinbyrne wants to merge 2 commits into
Conversation
Add STARTS_WITH, NOT_STARTS_WITH, ENDS_WITH, and NOT_ENDS_WITH to the PropertyOperator enum and implement matching in the local FlagEvaluator, mirroring the existing ICONTAINS case (stringify + case-fold both sides, prefix/suffix compare, negate for not_* variants). A missing property is treated as inconclusive, consistent with the other operators. Previously flags targeting on these operators could never be evaluated locally and always fell back to remote evaluation. Implements the "String prefix/suffix property filter operators" requirement from the local-feature-flag-evaluator contract. Generated-By: PostHog Code Task-Id: db3b3000-a83b-4ec8-b2e8-e51948d6cd92
Contributor
posthog-android Compliance ReportDate: 2026-08-11 16:15:36 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
|
Contributor
🦔 ReviewHog reviewed this pull requestFound 0 must fix, 0 should fix, 4 consider. Published 4 findings (view the review). |
Contributor
|
ReviewHog Alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏 |
Contributor
There was a problem hiding this comment.
ReviewHog Report
Changes
Issues: 4 issues
Files (5)
.changeset/string-prefix-suffix-operators.mdposthog-server/src/main/java/com/posthog/server/internal/FlagEvaluator.ktposthog/api/posthog.apiposthog/src/main/java/com/posthog/internal/GsonPropertyOperatorAdapter.ktposthog/src/main/java/com/posthog/internal/PostHogLocalEvaluationModels.kt
dustinbyrne
marked this pull request as ready for review
August 11, 2026 16:54
Contributor
|
Reviews (1): Last reviewed commit: "fix(posthog-server): align prefix suffix..." | Re-trigger Greptile |
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
The
local-feature-flag-evaluatorcross-SDK contract now requires the local evaluator to support thestarts_with,not_starts_with,ends_with, andnot_ends_withproperty-filter operators (see PostHog/posthog#72992, already shipped in posthog-js/node, python, php, ruby, go, and dotnet).posthog-serverwas missing these: thePropertyOperatorenum had no members for them, so any flag targeting on one of these operators fell through the matching switch toInconclusiveMatchException("Unknown operator: ...")and could never be evaluated locally — it always fell back to remote evaluation.Why: bring
posthog-server's local flag evaluation into parity with the shared SDK contract so these operators resolve locally instead of forcing a remote round-trip.This is purely additive and backward-compatible — it only makes previously-inconclusive evaluations resolve locally. No deprecation or major version needed.
Changes
STARTS_WITH,NOT_STARTS_WITH,ENDS_WITH,NOT_ENDS_WITHto thePropertyOperatorenum (plusfromStringand Gson serialization mappings).FlagEvaluator, mirroring the existingICONTAINScase: stringify both the property value and filter value, ASCII case-fold both, then prefix/suffix compare, negating for thenot_*variants. A missing property is treated as inconclusive, consistent with the other operators.posthog/api/posthog.apifor the new public enum members.posthog+posthog-serverminor).💚 How did you test it?
Added unit tests in
FlagEvaluatorTestcovering each new operator (matching and non-matching cases), ASCII-only case-folding at non-ASCII boundaries, and a missing-property → inconclusive case. Added wire-format parsing and serializer round-trip coverage for all four operators. Ran./gradlew :posthog:test :posthog-server:testandmake checkFormat.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Fully autonomous
Authored by PostHog Code (Claude Opus 4.8). Task: implement the "String prefix/suffix property filter operators" requirement added to the
local-feature-flag-evaluatorcontract for the JVM server SDK. Implementation follows the shared contract's ASCII-only case-folding requirement for prefix/suffix operators, while leaving the existingICONTAINSnormalization unchanged. Verified via new unit tests, the fullposthog-servertest suite, and spotless.Created with PostHog Code