fix(flags): honor versioned local property matching - #312
Conversation
posthog-go Compliance ReportDate: 2026-09-05 15:51:49 UTC ✅ All Tests Passed!111/111 tests passed Capture_V1 Tests✅ 94/94 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
Prompt To Fix All With AI### Issue 1
.changeset/versioned-property-matching.md:2
**Patch release breaks consumers**
If consumers use unkeyed composite literals for the exported `FeatureFlagsResponse` struct, adding `PropertyMatchingVersion` makes their code fail to compile. This changeset requests a patch release even though the repository's release policy reserves major releases for breaking changes. Please either use a non-breaking representation or mark the release accordingly.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(flags): reject dependencies evaluate..." | Re-trigger Greptile |
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "posthog-go": patch | |||
There was a problem hiding this comment.
Patch release breaks consumers
If consumers use unkeyed composite literals for the exported FeatureFlagsResponse struct, adding PropertyMatchingVersion makes their code fail to compile. This changeset requests a patch release even though the repository's release policy reserves major releases for breaking changes. Please either use a non-breaking representation or mark the release accordingly.
Prompt To Fix With AI
This is a comment left during a code review.
Path: .changeset/versioned-property-matching.md
Line: 2
Comment:
**Patch release breaks consumers**
If consumers use unkeyed composite literals for the exported `FeatureFlagsResponse` struct, adding `PropertyMatchingVersion` makes their code fail to compile. This changeset requests a patch release even though the repository's release policy reserves major releases for breaking changes. Please either use a non-breaking representation or mark the release accordingly.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
💡 Motivation and Context
Local flag evaluation needs to use the matching rules selected by the definitions response. This follows the backend change and shared SDK contract.
property_matching_versionfrom definitions. Missing, 1, and unknown versions keep released legacy matching. Exactly 2 uses explicit scalar equality and member equality for nonempty filter arrays. Empty filters keep recursive truthiness, andis_notcomplementsexactfor known properties. For example, version 2 stops matchingfalseagainst"banana"and matches["true", "false"]against"true".EvaluateFlags, capture enrichment, and recursive group/cohort/dependency evaluation. A version-only refresh takes effect even when flags are unchanged. A 304 retains the version, including when its ETag changes. Dependency result caches remain per evaluation.dependency_chaindecoding seam needed for recursive flag dependencies. JSON decodes chains as[]any, while the parser previously accepted only[]string. Accept either valid string-only form and leave malformed chains nil for the existing inconclusive path. Other parser behavior is unchanged.FeatureFlagsResponse.PropertyMatchingVersionfield addition.This deliberately reduces local coverage for dependencies across group contexts, including mixed-targeting dependencies that also have person conditions. Normal calls can fall back to
/flags. Local-only value and payload calls stay inconclusive, while bulk,EvaluateFlags, and capture paths omit unresolved flags without contacting the server.Missing-property and ambiguous integral-number safeguards remain unchanged. The existing patch changeset documents the matching and cohort-chain fixes. There is no new disk or shared cache provider, and already-returned evaluation results remain snapshots. This PR does not opt the Go adapter into the optional harness coverage.
Compatibility: Adding an exported field to
FeatureFlagsResponserequires consumers using unkeyed struct literals to update them. Keyed literals remain compatible.💚 How did you test it?
Added
featureflags_matching_version_test.gowith HTTP definitions-to-local-API tests for missing/1/2/unknown versions, scalar and array matching, negation, null/missing properties, Unicode and canonical values, version-only reloads, 304/error retention, groups, recursive cohorts, flag dependencies, and both capture paths. A deterministic mid-evaluation snapshot replacement verifies that definitions cannot mix across a single evaluation. Dependency-chain tests cover typed, JSON-decoded, and malformed inputs.Added
featureflags_cohort_continuity_test.goafter independently reproducing the continuity regression. It covers versions 0/1/2/3, enabled and disabled continuity, direct and cohort local-only evaluation, combined value/payload evaluation, raw and pre-parsed cohorts, and cached inconclusive dependencies. The regression failed before the fix and passes afterward. The API snapshot check also failed before regeneration and passes afterward.Added
featureflags_cohort_group_context_test.goafter independently reproducing both directions of the group-context bug. Its 76 cases cover flag-level and condition-level targeting, versions 0/1/2/3 for referenced group flags and 1/2 for group callers, OR/AND/nested/negated cohorts, indirect dependencies, raw and pre-parsed cohorts, and repeated cached references. Controls verify direct group flags, person-only dependencies, and group property-only cohorts still evaluate locally. Local-only value/payload/bulk/EvaluateFlags/capture paths make no remote requests. Both regressions failed before their respective fixes and pass afterward.Validation for
4bd87debb95d6311abb4c7ab0c835fc00b88fc05:All final checks passed. The full race suite passed all root-module packages, with the root package completing in 47.016s. Changed Go files are formatted. An earlier race run hit an existing shutdown timing assertion, and an intermediate test fixture needed its logger initialized. Both logs were retained and the final full suite passed. The first required committed-branch autoreview found the inverse group-to-person dependency bug. That finding was independently reproduced and fixed in a second new signed commit. The final isolated autoreview against
origin/mainreported no actionable findings for this exact commit. Live-service and cross-SDK harness integration were not run. These are local results, not a claim that CI passed.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset fileThe existing
.changeset/versioned-property-matching.mdpatch entry is included. The generator was not rerun. The public struct-literal compatibility caveat is described above.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Pi agents implemented, independently reviewed, and updated this change under human direction using file tools, Git, Go tests, GitHub CLI, and the isolated autoreview helper. The review fixes preserve continuity and group-context fallback boundaries and refresh the generated API snapshot. A private group-context marker was approved after the inverse dependency bug was reproduced. No public API or matching-rule changes were added by these fixes. The human-directed scope includes the narrow JSON dependency-chain fix, not broader parser cleanup. Human review is required before merge.
Session context is local and has no shareable URL. Review, reproduction, and publication evidence were retained outside the repository.