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

fix boolean handling #6

Merged
merged 1 commit into from
Oct 2, 2024
Merged

fix boolean handling #6

merged 1 commit into from
Oct 2, 2024

Conversation

bdchauvette
Copy link
Owner

This commit updates the boolean handling in two ways:

  • it uses the flag's enabled status as the source of truth if the value is nil
  • it treats a blank string as true

These changes are to accomodate quirks of setting flag values in the Flagsmith web UI.

This commit updates the boolean handling in two ways:

- it uses the flag's enabled status as the source of truth if the value is nil
- it treats a blank string as true

These changes are to accomodate quirks of setting flag values in the Flagsmith web UI.
Comment on lines +8 to +17
# When a flag is first created, Flagsmith sets the value to nil, and
# as long as the value is never changed through the UI, the value will
# stay as nil. In this case, the flag's enabled status should be used
# as the value of the flag.
#
# Note that in practice this particular code path SHOULD always return
# `true`, because the resolver bails out early and uses a default
# value if the flag is disabled. However, for the sake of correctness,
# we should still explicitly check the flag's enabled status here.
return flag.enabled? if value.nil?
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there is currently a bug in Flagsmith's ruby SDK that converts false flag values to nil:

            value: json_flag_data[:feature_state_value] || json_flag_data[:value],

source

I plan to open a PR upstream to fix that issue, but for now it means that fetch_boolean_value will always return true for an enabled flag that is explicitly set to false in the Flagsmith UI.

@bdchauvette bdchauvette merged commit 7a066b5 into main Oct 2, 2024
1 check passed
@bdchauvette bdchauvette deleted the fix-boolean-processing branch October 2, 2024 12:39
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.

1 participant