Skip to Content
LearnCode Review5 WhysFeature Flag Removal

Feature Flag Removal

This learning is based on a real production incident that affected customers.

Let’s examine how to properly manage feature flag removal, using a real-world example where premature flag removal caused a web application to crash.

The Scenario

A developer removed a feature flag from LaunchDarkly configuration before the code changes were deployed to production. While the changes were reviewed, they caused application failures because:

  1. The feature flag was removed before code changes were deployed.
  2. GraphQL queries expected non-null values for the flag.
  3. Error handling was insufficient.
  4. The review process didn’t catch the deployment timing issue.
  5. No automated checks prevented premature flag removal.
flags.ts
// GraphQL query expecting non-null flag const FEATURE_FLAGS_QUERY = gql` query FeatureFlags { featureFlags { lineaEnabled: flag(key: "linea-enabled") { enabled } } } ` // No error handling or fallback const { data } = useQuery(FEATURE_FLAGS_QUERY) const isLineaEnabled = data.featureFlags.lineaEnabled.enabled

PR Comment

Choose the comment that you think is the most constructive and helpful.

Click here to learn more

Key Lessons

1. Feature Flag Management

  • Verify code deployment before flag removal
  • Implement proper error handling
  • Provide fallback values
  • Monitor flag-related errors

2. Deployment Process

  • Follow deployment sequence
  • Verify production readiness
  • Document dependencies
  • Implement automated checks

3. Review Best Practices

  • Check deployment status
  • Verify error handling
  • Require fallback values
  • Consider failure modes

Tips for Reviewers

1. Ask Deployment Questions

  • Is the code deployed to production?
  • Are all environments ready?
  • How will errors be handled?
  • Example: “Has the code been deployed to all environments?“

2. Verify Error Handling

  • Are there fallback values?
  • How are errors logged?
  • Is there proper monitoring?
  • Example: “What happens if the flag is missing?“

3. Document Requirements

  • List deployment prerequisites
  • Note error handling needs
  • Document monitoring requirements
  • Example: “Code must be deployed before flag removal”

Common Pitfalls to Avoid

1. Focusing Only on Configuration

  • ❌ “The flag removal looks good, let’s merge.”
  • ✅ “The flag removal looks good, but let’s verify code deployment.”

2. Insufficient Error Handling

  • ❌ “The application will handle missing flags.”
  • ✅ “Let’s implement proper error handling and fallbacks.”

3. Missing Dependencies

  • ❌ “It’s just a flag removal.”
  • ✅ “This flag removal affects running code, let’s verify all dependencies.”

Remember: A good feature flag review considers deployment timing and error handling. Understanding the full impact of flag removal and maintaining proper safeguards helps prevent application failures!

Last updated on