Feature Flag Default Value Strategies
Choose the right default values for feature flags based on the flag's purpose. Covers fail-safe defaults, platform-specific defaults, and fallback chains.
Detailed Explanation
Default Value Strategies
The default value of a feature flag determines what happens when the flag system is unavailable, when a user doesn't match any targeting rules, or when the flag is evaluated for the first time. Choosing the right default is critical for system reliability.
The Golden Rule
The default value should represent the safest, most conservative behavior.
For new features: default to OFF (don't show the feature). For kill switches: default to ON (keep the system running).
Configuration Examples
{
"new-feature": {
"type": "boolean",
"defaultValue": false,
"description": "New feature -- safe to hide if flag service is down"
},
"payment-enabled": {
"type": "boolean",
"defaultValue": true,
"description": "Kill switch -- must work even if flag service is down"
},
"api-timeout-ms": {
"type": "number",
"defaultValue": 5000,
"description": "Conservative timeout -- higher default is safer"
},
"theme": {
"type": "string",
"defaultValue": "system",
"description": "Follows system preference if flag service is unavailable"
}
}
Default Value Decision Matrix
| Flag Purpose | Type | Recommended Default | Reasoning |
|---|---|---|---|
| New feature | boolean | false |
Don't expose incomplete features |
| Kill switch | boolean | true |
Service should work without flags |
| Rate limit | number | Conservative value | Higher limits are safer than lower |
| Timeout | number | Higher value | Better slow than failing |
| UI variant | string | Current/original | Don't change UX unexpectedly |
| Config object | json | Minimal safe config | Include only required fields |
SDK-Level Defaults
Most SDKs let you specify a fallback when evaluating a flag:
// Application-level default as final fallback
const showFeature = client.boolVariation(
"new-feature",
user,
false // SDK-level fallback if flag not found
);
Fallback Chain
The evaluation order for defaults:
- Targeting rules match → Rule's variation value
- No rules match, flag ON → Flag's fallthrough value
- Flag is OFF → Flag's off variation
- Flag not found → SDK-level default parameter
- SDK not initialized → Application hardcoded default
Common Mistakes
- Setting a new feature's default to
true(exposed before ready) - Using
0as default for rate limits (blocks all requests) - Empty string defaults for required string configs
- Not testing what happens when the flag service is completely unavailable
Use Case
A team reviews their feature flag defaults during an incident postmortem. They discovered that when their flag service had a brief outage, a new feature with a 'true' default was accidentally exposed to all users. They establish a policy that all new feature flags must default to false, while kill switches default to true.