Skip to content

Commit

Permalink
Ensure metadata.display_defaults exists
Browse files Browse the repository at this point in the history
A bug was introduced in PR #1280 where datasets which did not
define `metadata.display_defaults` would crash, as the code assumed
its existence. This property is optional in the dataset
JSON.

This commit ensures `display_defaults` exists in redux state after
a dataset is loaded, thus allowing code to rely on its presence.
This was preferred to checking for `display_defaults` in (all) the
relevant sections of code, now and in future.

(Using TypeScript, or expanding our smoke tests, would be approaches
to avoiding these kinds of bugs in future.)
  • Loading branch information
jameshadfield committed Mar 18, 2021
1 parent e96d002 commit 5202755
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
title: Changelog
---

## version 2.24.0 - 2021/03/17

* [bugfix] Fixes a bug introduced in v2.24.0 where certain datasets wouldn't load

## version 2.24.0 - 2021/03/17

* Frequencies are no longer normalized when the data is lacking.
See [PR 1278](https://github.com/nextstrain/auspice/pull/1278) for more.
Expand Down
2 changes: 2 additions & 0 deletions src/actions/recomputeReduxState.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ const modifyStateViaMetadata = (state, metadata) => {
}
}
}
} else {
metadata.displayDefaults = {}; // allows code to rely on `displayDefaults` existing
}

if (metadata.panels) {
Expand Down

0 comments on commit 5202755

Please sign in to comment.