CI/CD / Promotion and environment contracts / Lesson 14
Feature flags and release boundaries
Plan, evaluate and retire a release flag with explicit defaults, context and observability.
On this page
Lesson goals
- Distinguish deployment of code from enabling its behavior.
- Test flag defaults, targeting and rollback in a bounded environment.
Separate deployment from enablement
A release flag can select between code paths after a candidate is deployed. This adds a control boundary: the artifact, flag configuration and evaluation context together determine behavior. Record the owner, intended population, default and retirement condition before rollout. A flag does not reverse an incompatible database migration or an external effect that already occurred, so retain a separate recovery plan.
Inspect a synthetic test cohort
The first fixture illustrates a test cohort receiving the new checkout path while the declared default is false. It is a planning record rather than a particular provider’s API or an executed evaluation. A real flag system must define how context, rules and errors produce a result. Do not place personal data or credentials in evaluation context merely to make targeting convenient.
{"flag":"new-checkout","default":false,"context":{"cohort":"test"},"result":true}
The fixture declares one flag result and default; it does not contact a provider.
Compare a control cohort
The second fixture shows the control cohort receiving false under the same named flag. Compare both outcomes using the same artifact and intended configuration version, and verify that users stay in the intended cohort according to the chosen provider’s documented rules. A single successful evaluation does not prove that every instance received the updated configuration or that a notification reached an operator.
{"flag":"new-checkout","default":false,"context":{"cohort":"control"},"result":false}
The example selects the existing path for control; actual targeting is provider-specific.
Define failure and rollback behavior
Choose an explicit default for an unavailable provider or invalid context and test it with the deployed SDK. Record propagation assumptions and the maximum acceptable time to disable the new path. A flag reversal changes future evaluations according to the implementation; it does not automatically undo previously written data. Monitor errors and business outcomes for both cohorts without logging sensitive context.
Verify and remove the flag
In a disposable environment, test enabled, disabled, missing-context and provider-failure cases with synthetic identities. Compare the observed path and sanitized evaluation evidence with the documented default, then rehearse disabling the new path. Once the release is stable, remove obsolete branches and configuration through a reviewed change. Leaving temporary flags indefinitely increases combinations that future tests and maintainers must understand.
Common errors and fixes
A provider outage enables an unfinished path.
- Why it happens
- The fallback was not defined or tested.
- How to fix it
- Choose and verify an explicit safe default for the use case.
- Prevent it next time
- Exercise provider failure before release.
Disabling the flag is assumed to undo a data migration.
- Why it happens
- Future code selection was confused with reversal of past effects.
- How to fix it
- Reconcile the data and apply the documented recovery plan.
- Prevent it next time
- Review data compatibility and rollback separately.
Sensitive user details appear in flag logs.
- Why it happens
- Evaluation context was not minimized.
- How to fix it
- Remove sensitive fields and follow the data response process.
- Prevent it next time
- Use approved synthetic or minimal context identifiers.
2 practice exercises
1. The new path wrote a record before the flag was disabled. Is the record automatically removed?
Show worked solution
No. Flag evaluation controls a subsequent code path according to its implementation; it does not automatically reverse a previous write. Reconcile the record and follow the separate data recovery contract.
2. What should be checked when the provider is unavailable?
Show worked solution
Check the SDK’s actual fallback behavior against the documented default, observe the selected path in an isolated test and ensure the application handles the failure without leaking context or assuming propagation succeeded.
Key takeaways
- A release flag adds configuration and context to candidate identity.
- Test defaults, propagation and data recovery independently.