Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default feature flags as an object (#5810)
When an expected flag is not provided by `environment.featureFlags`, the missing value is taken from a [string](https://github.com/dfinity/nns-dapp/blob/662509773a569ec966ce7cfcf2ee437ff1f55e9a/frontend/src/lib/constants/environment.constants.ts#L32) that is supposed to contain all default values. The issue is that this approach cannot be verified, and it already omits some values, which could lead to a broken app state when environment constants are missing or outdated. In cases where the `featureFlags` environment variable is empty or not provided, the dapp breaks with a dev console error: `Uncaught (in promise) Error: Missing mandatory environment variables: featureFlags` This error is self-explanatory, so no changes are needed to handle this specific case. However, when there are missing entries in the environment variable (e.g., `record { 0="FEATURE_FLAGS"; 1="{}" };`), the dapp also breaks with the error:`Error: derived() expects stores as input, got a falsy value.` This happens because no derived store is created for the missing value(s). While we could modify the store creation mechanism to always initialize with the `false` value, I believe having explicitly set default values is a better solution. # Changes - Add `defaultFeatureFlagValues: FeatureFlags<boolean>`. - Replace missing flags with the entries from `defaultFeatureFlagValues`. # Tests - Added a unit test to verify that the default flags are used. - Tested manually: reproduced the issue with the current nns-dapp and missing flags, then confirmed that the updated version works with the default flags. # Todos - [ ] Add entry to changelog (if necessary). Not necessary.
- Loading branch information