Ensure reset of feature flags and constants after config deployment#871
Merged
shirasassoon merged 54 commits intomicrosoft:mainfrom Mar 11, 2026
Merged
Conversation
added 2 commits
March 11, 2026 11:06
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses state leakage during deploy_with_config by ensuring feature flags and constant overrides applied from a YAML config are reverted after the deployment completes, and strengthens config validation (notably around YAML parsing and constants/features environment mappings).
Changes:
- Replaced config override mutation with a
config_overrides_scopecontext manager to guarantee restoration of feature flags/constants after deployment (including on exceptions). - Enhanced config validator behavior: duplicate YAML key detection, improved constants section validation (per-key env mappings), and expanded error-path coverage in tests.
- Updated docs and changelog entry to reflect new validation/override behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/fabric_cicd/publish.py |
Wrapes config-based deployment execution in a context manager scope to ensure overrides are reverted. |
src/fabric_cicd/_common/_config_utils.py |
Introduces config_overrides_scope to apply and reliably restore overrides. |
src/fabric_cicd/_common/_config_validator.py |
Adds duplicate YAML key detection and refactors constants/features environment validation logic. |
tests/test_deploy_with_config.py |
Adds/updates tests asserting overrides are applied only within scope and restored afterward. |
tests/test_config_validator.py |
Adds broader validator test coverage for error cases, env mapping behavior, and duplicate key detection. |
docs/how_to/config_deployment.md |
Updates documentation to reflect warning-level logging behavior. |
.changes/unreleased/fixed-20260311-110454.yaml |
Adds release note entry for the fix. |
ayeshurun
reviewed
Mar 11, 2026
ayeshurun
reviewed
Mar 11, 2026
ayeshurun
reviewed
Mar 11, 2026
ayeshurun
approved these changes
Mar 11, 2026
ayeshurun
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #872
This pull request introduces a robust and safer mechanism for handling feature flag and constant overrides during configuration-based deployments. The main improvement is the replacement of the previous global override function with a context manager, ensuring that any changes to feature flags and constants are always reverted after deployment, even if errors occur. This prevents state leakage between deployments and improves reliability. The pull request also updates validation logic, enhances logging, and adds comprehensive tests to verify correct override and restoration behavior.
Key changes include:
Override Mechanism Improvements
apply_config_overridesfunction with aconfig_overrides_scopecontext manager insrc/fabric_cicd/_common/_config_utils.py. This ensures that feature flags and constants are overridden only for the duration of the deployment and are always restored to their original values afterward, even if exceptions occur. [1] [2] [3]Validation and Logging Enhancements
featuresandconstantssections, including more granular checks for environment-specific mappings and individual constant keys. [1] [2] [3]featuresandconstantsto warnings instead of debug, making potential misconfigurations more visible. [1] [2]Testing Improvements
Documentation
featuresandconstants.Bug Fix