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

Updating multivariate weighting in one environment appears to update in all #421

Closed
matthewelwell opened this issue Oct 19, 2021 · 1 comment · Fixed by #423
Closed

Updating multivariate weighting in one environment appears to update in all #421

matthewelwell opened this issue Oct 19, 2021 · 1 comment · Fixed by #423
Assignees
Labels
bug Something isn't working front-end Issue related to the React Front End Dashboard

Comments

@matthewelwell
Copy link
Contributor

The issue seems to stem from confusion around the difference between thedefault_percentage_allocation value and the
percentage_allocation value. The default_percentage_allocation value should only be set once, on creation, similar
to the default_enabled value of a feature state.

From what I can tell, the FE is using the default_percentage_allocation value to display the current percentage
allocation for a variant in a given environment which is incorrect. It is also updating this value whenever the user
updates the value in a given environment.

Here is an example journey with some of these key points highlighted:

Step 1. User creates a new feature with a multivariate option.

POST request made to /projects/:id/features/ with the following request body:

{
  "name": "mvtest2",
  "initial_value": "control",
  "default_enabled": true,
  "multivariate_options": [
    {
      "type": "unicode",
      "boolean_value": null,
      "integer_value": null,
      "string_value": "variant-1",
      "default_percentage_allocation": 5
    }
  ],
  "project": "3053",
  "type": "MULTIVARIATE"
}

Step 2. User reviews features in an environment

GET request made to /api/v1/features/featurestates/?environment=:id&feature=:id with the following response body

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 70904,
      "feature_state_value": {
        "type": "unicode",
        "string_value": "control",
        "integer_value": null,
        "boolean_value": null
      },
      "multivariate_feature_state_values": [
        {
          "id": 2352,
          "multivariate_feature_option": 686,
          "percentage_allocation": 5.0
        }
      ],
      "enabled": true,
      "feature": 13309,
      "environment": 7478,
      "identity": null,
      "feature_segment": null
    }
  ]
}

Note the value of results.0.multivariate_feature_state_values.0.percentage_allocation is 5.0 as expected. As I
understand it, however, this is not the value that the FE is using to display to the user, it's using the value of
default_percentage_allocation that it retrieves using the response from /api/v1/projects/:id/features/.

Step 3. User updates the percentage weighting in a given environment

At this point, 2 PUT requests are made

One to /api/v1/environments/:id/featurestates/:id/ with the following request body

{
  "id": 70903,
  "feature_state_value": "control",
  "multivariate_feature_state_values": [
    {
      "id": 2351,
      "multivariate_feature_option": 686,
      "percentage_allocation": 10
    }
  ],
  "identity": null,
  "enabled": true,
  "feature": 13309,
  "environment": 7477,
  "feature_segment": null
}

This is correct.

The FE also makes another PUT request to /api/v1/projects/:id/features/:id/ with the following body:

{
  "id": 13309,
  "name": "mvtest2",
  "type": "MULTIVARIATE",
  "default_enabled": true,
  "initial_value": "control",
  "created_date": "2021-10-19T10:10:21.307968Z",
  "description": null,
  "tags": [],
  "multivariate_options": [
    {
      "id": 686,
      "type": "unicode",
      "integer_value": null,
      "string_value": "variant-1",
      "boolean_value": null,
      "default_percentage_allocation": 10
    }
  ],
  "is_archived": false,
  "project": "3053"
}

The default_percentage_allocation value on the multivariate options should not be updated in this request, this value
should only be set when creating a multivariate option.

So, in summary, 2 issues:

  1. FE is displaying the default_percentage_allocation instead of percentage_allocation.
  2. FE is updating the default_percentage_allocation value of already existing multivariate options.
@matthewelwell matthewelwell added bug Something isn't working front-end Issue related to the React Front End Dashboard labels Oct 19, 2021
@dabeeeenster dabeeeenster added this to the Front End ToDo milestone Oct 19, 2021
@kyle-ssg
Copy link
Member

#423

@dabeeeenster dabeeeenster linked a pull request Oct 19, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants