Skip to content

fix: $group_key should be override in local eval #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 23, 2025

Conversation

orian
Copy link
Contributor

@orian orian commented May 23, 2025

Fixes missing $group_key override

fixes: #98

@orian orian requested a review from a team May 23, 2025 13:46
@haacked haacked requested a review from Copilot May 23, 2025 17:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that the $group_key is correctly injected into group-based feature‐flag evaluations by cloning the original properties and avoiding side effects. It also renames several “Decide” methods to “Remote” and updates tests and fixtures to cover the new behavior.

  • Added a Clone method on Properties to safely duplicate maps.
  • Swapped getFeatureFlag*FromDecide calls for *FromRemote in posthog.go.
  • Injected $group_key into the cloned group properties in computeFlagLocally and added corresponding tests/fixtures.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
properties.go Added Clone() for Properties and adjusted the doc comment.
posthog.go Renamed “Decide” methods to “Remote” and updated interface comments.
groups.go Fixed the type comment for Groups.
groups_test.go Switched to table-driven tests using testify/require.
fixtures/feature_flag/*.json Added JSON fixtures for group props and false-variant scenarios.
featureflags.go Cloned and injected $group_key into group properties during local evaluation.
feature_flags_local_test.go Expanded local-eval tests (note: missing imports).
Comments suppressed due to low confidence (2)

groups.go:4

  • Grammar issue: change "a free-form objects" to "a free-form object" (singular) to match the type.
// a free-form objects so the application can set any value it sees fit but

feature_flags_local_test.go:94

  • The test uses require assertions but the testify/require package is not imported. Add "github.com/stretchr/testify/require" (and other needed imports like net/http/httptest and strings) to the import block.
require.Error(t, err)

Copy link
Contributor

@haacked haacked left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@orian orian merged commit 501e56c into master May 23, 2025
1 check passed
@orian orian deleted the pawel/fix/group-overrides branch May 23, 2025 22:36
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.

Difference in behavior from node sdk on local evaluation
2 participants