LaunchDarkly
This learning is based on a real production incident that affected customers.
Let’s examine how to properly manage LaunchDarkly flags and their rules, using a real-world example where incorrect flag configuration led to disabled blockchain withdrawals.
The Scenario
A developer updated LaunchDarkly flags to include a new segment. While the changes were tested and reviewed, they inadvertently affected blockchain withdrawal permissions because:
- Rules were added as
orwhen they should have beenand. - Limited access to LaunchDarkly configuration meant few engineers could review.
- Manual testing didn’t catch all the configuration issues.
- No standardized practices for flag rule management.
- No infrastructure for proper review of flag changes.
Before
launchdarkly.ts
const rules = [
{
segment: 'new_segment',
value: true
},
{
user: 'specific_user',
value: true
},
]PR Comment
Choose the comment that you think is the most constructive and helpful.
Click here to learn more
Key Lessons
1. Understanding Flag Rules
- Know how rules combine (AND vs OR)
- Document the intended behavior
- Verify rule interactions
- Test all affected features
2. Review Process
- Ensure multiple engineers can review changes
- Use infrastructure as code for flag management
- Document review requirements
- Consider automated testing
3. Best Practices
- Standardize flag management processes
- Create clear documentation
- Implement proper access controls
- Use infrastructure as code
Tips for Reviewers
1. Ask Rule-Focused Questions
- How should these rules combine?
- What’s the intended behavior?
- How do we verify the logic?
- Example: “Should these rules work as AND or OR?“
2. Verify Testing Strategy
- Are all affected features tested?
- Is there automated testing?
- Do we have proper test coverage?
- Example: “Let’s add tests for the flag configurations”
3. Document Dependencies
- List affected features
- Note required permissions
- Document rule interactions
- Example: “Blockchain withdrawals depend on these flags”
Common Pitfalls to Avoid
1. Focusing Only on Changes
- ❌ “The flag changes look good, let’s merge.”
- ✅ “The flag changes look good, but let’s verify the rule logic.”
2. Assuming Manual Testing is Sufficient
- ❌ “We tested it manually, so it’s good.”
- ✅ “We tested it manually, but let’s add automated tests.”
3. Missing Rule Interactions
- ❌ “These are just flag changes.”
- ✅ “These flag changes affect multiple features, let’s verify them all.”
Remember: A good code review considers both the technical implementation and the business logic. Understanding how flag rules work and their impact helps prevent issues before they reach production!
Last updated on