Skip to content
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

fix: support audience ids #161

Merged
merged 3 commits into from
Oct 31, 2019
Merged

fix: support audience ids #161

merged 3 commits into from
Oct 31, 2019

Conversation

mikeproeng37
Copy link
Contributor

Summary

  • Fixes bug where experiment.audienceIds is not parsed into audience condition tree in the absence of experiment.audienceConditions
  • Fixes bug where user attribute lookup returns error when attribute not found during condition matching, and thus results in the not condition being short-circuited to false

Copy link
Contributor

@mikecdavis mikecdavis left a comment

Choose a reason for hiding this comment

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

LGTM, but I'm not quite sure I understand why we needed to change from returning the err, to always returning nil. Minor comment on lack of coverage that could result in a future regression albeit that it should be covered by the compat suite. Perhaps add a follow-up ticket for that fixture?

@@ -34,23 +34,23 @@ func (m ExactMatcher) Match(user entities.UserContext) (bool, error) {
if stringValue, ok := m.Condition.Value.(string); ok {
attributeValue, err := user.GetStringAttribute(m.Condition.Name)
if err != nil {
return false, err
return false, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we log that we're swallowing these errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the error here means that the user does not have that attribute key we are looking for. I can log it as debug but that might be a bit too noisy, wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created JIRA ticket to track this.

var audienceConditionTree *entities.TreeNode
var err error
if rawExperiment.AudienceConditions == nil && len(rawExperiment.AudienceIds) > 0 {
audienceConditionTree, err = buildAudienceConditionTree(rawExperiment.AudienceIds)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have coverage on this path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added it.

@mikeproeng37
Copy link
Contributor Author

LGTM, but I'm not quite sure I understand why we needed to change from returning the err, to always returning nil. Minor comment on lack of coverage that could result in a future regression albeit that it should be covered by the compat suite. Perhaps add a follow-up ticket for that fixture?

I tried to explain this in the summary 😄. It boils down to the error being used to return false but that breaks the not operator since the attribute not being present means that not [condition] should evaluate to true.

@mikeproeng37 mikeproeng37 merged commit e9a646e into master Oct 31, 2019
@mikeproeng37 mikeproeng37 deleted the mng/support-audience-ids branch October 31, 2019 18:49
@@ -42,7 +42,7 @@ type Experiment struct {
TrafficAllocation []trafficAllocation `json:"trafficAllocation"`
AudienceIds []string `json:"audienceIds"`
ForcedVariations map[string]string `json:"forcedVariations"`
AudienceConditions interface{} `json:"audienceConditions"`
Copy link
Contributor

@yasirfolio3 yasirfolio3 Nov 4, 2019

Choose a reason for hiding this comment

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

@mikeng13 this change is causing issues for datafiles with audience conditions defined as:
"audienceConditions": "20413101795", i have fixed it in this PR #165

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.

3 participants