Skip to content

Commit

Permalink
bug(nimbus): handle None in results data (#12101)
Browse files Browse the repository at this point in the history
Becuase

* We recently added the show results url link on the landing page
* That involves checking the contents of the results data payload
* In old experiments, some keys unexpected contain null/None values
* The method to check did not handle this case and was raising 500

This commit

* Adds a test case for null values in the results data payload
* Handles the null case in the show results data method

fixes #12094
  • Loading branch information
jaredlockhart authored Jan 23, 2025
1 parent 939219c commit 8a64f4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion experimenter/experimenter/experiments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ def has_displayable_results(self):
if self.results_data and "v3" in self.results_data:
results_data = self.results_data["v3"]
for window in ["overall", "weekly"]:
if window in results_data:
if results_data.get(window):
enrollments = results_data[window].get("enrollments", {}).get("all")
if enrollments is not None:
return True
Expand Down
1 change: 1 addition & 0 deletions experimenter/experimenter/experiments/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ def test_has_displayable_results_true(self, results_data):
({"v3": {"weekly": {"enrollments": {}}}},),
({"v3": {"overall": {"enrollments": {"all": None}}}},),
({"v3": {"weekly": {"enrollments": {"all": None}}}},),
({"v3": {"overall": None}},),
]
)
def test_has_displayable_results_false(self, results_data):
Expand Down

0 comments on commit 8a64f4f

Please sign in to comment.