Skip to content

Ensure reset of feature flags and constants after config deployment#871

Merged
shirasassoon merged 54 commits intomicrosoft:mainfrom
shirasassoon:add_global_resets_config_deploy
Mar 11, 2026
Merged

Ensure reset of feature flags and constants after config deployment#871
shirasassoon merged 54 commits intomicrosoft:mainfrom
shirasassoon:add_global_resets_config_deploy

Conversation

@shirasassoon
Copy link
Contributor

@shirasassoon shirasassoon commented Mar 11, 2026

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

  • Replaced the global apply_config_overrides function with a config_overrides_scope context manager in src/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]
  • Updated all usages and tests to use the new context manager, removing references to the old function. [1] [2]

Validation and Logging Enhancements

  • Improved validation logic for the features and constants sections, including more granular checks for environment-specific mappings and individual constant keys. [1] [2] [3]
  • Changed the logging level for skipped features and constants to warnings instead of debug, making potential misconfigurations more visible. [1] [2]

Testing Improvements

  • Added extensive tests to verify that feature flags and constants are correctly overridden within the context and always restored after, including when exceptions are raised. Tests also check that user-set values are preserved and that environment-specific overrides work as intended.

Documentation

  • Updated documentation to reflect the new override behavior and logging changes for features and constants.

Bug Fix

Shira Sassoon and others added 30 commits September 4, 2025 19:53
@shirasassoon shirasassoon marked this pull request as ready for review March 11, 2026 09:05
Copilot AI review requested due to automatic review settings March 11, 2026 09:05
Shira Sassoon added 2 commits March 11, 2026 11:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_scope context 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.

@shirasassoon shirasassoon merged commit 7400852 into microsoft:main Mar 11, 2026
13 checks passed
@shirasassoon shirasassoon deleted the add_global_resets_config_deploy branch March 11, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Ensure Reset of Feature Flags and Constants after Config Deployment

3 participants