https://www.growthbook.io/ logo
#contributing
Title
# contributing
n

narrow-psychiatrist-15437

04/20/2022, 1:44 PM
Hi! What would be the best way to determine if a feature flag is disabled when fetching feature flags from the API (
<https://cdn.growthbook.io/api/features/[key]>
)? Is it safe to assume that
defaultValue
is always set to
null
for a disabled feature?
It would be nice to have an
enabled
boolean property, and include the
rules
array for all feature flags, regardless if they're enabled or not.
f

future-teacher-7046

04/20/2022, 1:47 PM
Yea, there's no perfect way right now to differentiate the enabled state. If a feature is disabled for an environment, it will be set to
{"defaultValue": null}
with no rules. However, it's possible for a feature to be "enabled" in the environment, but still have the default value set to null and no rules.
What is your specific use case where you need to identify the disabled features?
n

narrow-psychiatrist-15437

04/20/2022, 4:38 PM
I see! I'll filter by
defaultValue
then, and always make sure to set a default value for enabled features. We're integrating Growthbook with Sanity Studio to be able to deploy A/B tests without pushing any code. To avoid having to copy-paste the name of a feature flag from Growthbook to Sanity, I'm creating a custom select component that is pre-populated with the currently enabled feature flags.
f

future-teacher-7046

04/20/2022, 4:49 PM
ok, that makes sense. We were thinking of just removing disabled features from the JSON response entirely (the default for unknown features is
null
anyway, so the behavior is the same).
c

careful-planet-92513

04/20/2022, 5:33 PM
+1 to removing them from the JSON response (if you are looking for validation on that) ^ on tangible benefit is that we would not leak upcoming features as they are being developed on in dev
n

narrow-psychiatrist-15437

04/21/2022, 8:52 AM
@future-teacher-7046 That would make more sense to me as well!
f

future-teacher-7046

05/01/2022, 1:11 PM
I just pushed this change. Disabled features are no longer included in the API response
🙌 1
c

careful-planet-92513

05/02/2022, 11:17 PM
woo, awesome!
8 Views