Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default feature flags as an object #5810

Merged
merged 10 commits into from
Nov 22, 2024
Merged

Conversation

mstrasinskis
Copy link
Contributor

@mstrasinskis mstrasinskis commented Nov 19, 2024

When an expected flag is not provided by environment.featureFlags, the missing value is taken from a string 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.

@mstrasinskis mstrasinskis marked this pull request as ready for review November 21, 2024 11:44
@mstrasinskis mstrasinskis requested a review from a team as a code owner November 21, 2024 11:44
@mstrasinskis mstrasinskis added this pull request to the merge queue Nov 22, 2024
Merged via the queue into main with commit 9979071 Nov 22, 2024
30 checks passed
@mstrasinskis mstrasinskis deleted the test-feature-flags-fallback branch November 22, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants