Updating advanced targeting doesn't update targeting in recipe
I just noticed that if you create an experiment with an advanced targeting, send it to preview, send it back to draft, then change the targeting config back to 'no targeting (all users)' save, and send back to preview, the targeting string in the recipe will still have the old advanced targeting, so that's a bug.
┆Issue is synchronized with this Jira Task
➤ Yashika Khurana commented:
jexlTargetingExpression"(experiment.slug in activeExperiments (currentDatedate - profileAgeCreateddate) / 86400000 >= 28 && userMonthlyActivitylength >= 7 && userMonthlyActivitylength <= 13 && doesAppNeedPin && isDefaultBrowser) && ('app.shield.optoutstudies.enabled'preferenceValue)"jexlTargetingExpression"('app.shield.optoutstudies.enabled'preferenceValue)"
I tried to replicate that:
before - custom targeting
after selecting -No targeting
jexlTargetingExpression
"(experiment.slug in activeExperiments || (currentDate|date - profileAgeCreated|date) / 86400000 >= 28 && userMonthlyActivity|length >= 7 && userMonthlyActivity|length <= 13 && doesAppNeedPin && isDefaultBrowser) && ('app.shield.optoutstudies.enabled'|preferenceValue)"
jexlTargetingExpression
"('app.shield.optoutstudies.enabled'|preferenceValue)"
@jaredlockhart so the 2nd one should be empty???
@yashika-khurana Oh no that's the correct behaviour, that's not what I was seeing when I tried it, let me try it again.
Okay I see this is actually a bug right here:
https://github.com/mozilla/experimenter/blob/51d02c7f82d88593434b175269a9a04d6c1c7b2d/app/experimenter/kinto/tasks.py#L380-L383
When leaving Preview back to Draft, the record should be deleted and published_dto should be set back to None, but it looks like it's crashing on the delete step so it's never hitting the published_dto=None step.
It's difficult to fix this just with unit tests since they mock out the Remote Settings side, so we should add some integration tests that publish to preview, check that it's in preview, then unpublish from preview, and check that it's removed from remote settings. Then once we have that fixed we can add some unit tests to mock out the real remote settings behaviour.
Just caught this locally:
In [25]: client.delete_record('asdf')
INFO 2022-06-07 20:20:39,297 kinto_http.client Delete record with id 'asdf' from collection 'nimbus-preview' in bucket 'main-workspace'
INFO 2022-06-07 20:20:39,322 kinto_http.client Patch collection 'nimbus-preview' in bucket 'main-workspace'
---------------------------------------------------------------------------
KintoException Traceback (most recent call last)
<ipython-input-25-19692b591acc> in <module>
----> 1 client.delete_record('asdf')
/app/experimenter/kinto/client.py in delete_record(self, id)
64 bucket=settings.KINTO_BUCKET_WORKSPACE,
65 )
---> 66 self._patch_collection()
67
68 def has_pending_review(self):
/app/experimenter/kinto/client.py in _patch_collection(self)
34 )
35 else:
---> 36 self.kinto_http_client.patch_collection(
37 id=self.collection,
38 data={"status": KINTO_SIGN_STATUS},
/usr/local/lib/python3.9/site-packages/backoff/_sync.py in retry(*args, **kwargs)
92
93 try:
---> 94 ret = target(*args, **kwargs)
95 except exception as e:
96 max_tries_exceeded = (tries == max_tries_)
/usr/local/lib/python3.9/site-packages/kinto_http/client.py in patch_collection(self, id, bucket, changes, data, original, permissions, safe, if_match)
591 )
592
--> 593 return self._patch_method(
594 endpoint, changes, data=data, permissions=permissions, safe=safe, if_match=if_match
595 )
/usr/local/lib/python3.9/site-packages/backoff/_sync.py in retry(*args, **kwargs)
92
93 try:
---> 94 ret = target(*args, **kwargs)
95 except exception as e:
96 max_tries_exceeded = (tries == max_tries_)
/usr/local/lib/python3.9/site-packages/kinto_http/client.py in _patch_method(self, endpoint, patch, safe, if_match, data, permissions)
181 headers["Content-Type"] = content_type
182
--> 183 resp, _ = self.session.request("patch", endpoint, payload=body, headers=headers)
184 return resp
185
/usr/local/lib/python3.9/site-packages/kinto_http/session.py in request(self, method, endpoint, data, permissions, payload, **kwargs)
134 exception.request = resp.request
135 exception.response = resp
--> 136 raise exception
137 if resp.status_code == 204 or resp.status_code == 304 or method == "head":
138 body = None
KintoException: PATCH /v1/buckets/main-workspace/collections/nimbus-preview - 403 403 - {'code': 403, 'errno': 121, 'error': 'Forbidden', 'message': 'Not in nimbus-preview-reviewers group'}
➤ Yashika Khurana commented:
This error is identified in the local environment only. The main cause is the permission issue and works fine on stage and prod
Okay i'll close this