Hi Everyone, I’ve been running into an issue with ...
# ask-questions
b
Hi Everyone, I’ve been running into an issue with our experiment setup. I use the API to update experiment and feature flag details, and then link them together. However, on several occasions I’ve noticed that after setting the variations (e.g., x and y), the feature flag later shows both variations as serving “null” (screenshot attached). Could you help me investigate the root cause of this? Many thanks,
s
Hi there! Nothing comes to mind right away here. Are you able share an example of your experiment/feature api call?
b
Hi @strong-mouse-55694, thanks for jumping in! Here’s a simplified view of how I’m setting things up through the API: • I create (or fetch) the project and environments. • Ensure SDK connections exist for each environment. • Delete/re-create the feature with a default value (
variationA
). • Create or update an experiment with two variations: ◦
variationA
variationB
• Link the experiment back to the feature by posting a payload with: ◦ a couple of test “force” rules for specific user_ids ◦ then an
experiment-ref
rule, where I map the experiment’s variationIds to the feature values. • Finally, I set the experiment status to
running
. Here’s the relevant snippet for the linking step (the part I suspect may be causing the null issue later on):
Copy code
{
  "type": "experiment-ref",
  "enabled": true,
  "condition": "",
  "hashAttribute": "user_id",
  "experimentId": experiment["id"],
  "variations": [
    {"variationId": v["variationId"], "value": v["key"]}
    for v in experiment.get("variations", [])
  ]
}
So the feature ends up with rules like: • force →
no-recommendations
• force →
personalize-recommendations
• experiment-ref → falls back to the experiment Do you know if there are any pitfalls with how
experiment-ref
rules need to be structured, or if the mapping of
variationId → value
might be why the flag sometimes reverts to “null” in both variations?
s
Nothing jumps out, but I'd first check the
variations
array. I'd probably try creating an experiment/flag with hardcoded values as a test case and see if the behavior is the same. If that works, I think there's likely something in how variations is being written.
b
Thanks a lot @strong-mouse-55694 When I first link the experiment to the feature, the variations look correct for the first couple of days. But after a few weeks, when I check back, some of the features (and not all) end up showing
"null"
being served for both variations.
s
That's really weird. If you look at the audit log, can you see any changes being made that would change the values?