Skip to content

AAP-65260: feature flag restore#942

Merged
zkayyali812 merged 1 commit intoansible:develfrom
zkayyali812:AAP-56260
Feb 13, 2026
Merged

AAP-65260: feature flag restore#942
zkayyali812 merged 1 commit intoansible:develfrom
zkayyali812:AAP-56260

Conversation

@zkayyali812
Copy link
Copy Markdown
Contributor

@zkayyali812 zkayyali812 commented Feb 13, 2026

Description

Alternativate fix to - #918, with more concise check and corrected log message

  • What is being changed?
    Adds logic to block feature flags loading code from running during partial migrations
  • Why is this change needed?
    This change is needed to ensure restore flow works reliably
  • How does this change address the issue?
    This change addresses the issue by adding a guard to ensure that the feature flags load logic does not run when migrations are incomplete

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Self-Review Checklist

  • I have performed a self-review of my code
  • I have added relevant comments to complex code sections
  • I have updated documentation where needed
  • I have considered the security impact of these changes
  • I have considered performance implications
  • I have thought about error handling and edge cases
  • I have tested the changes in my local environment

Testing Instructions

Prerequisites

Steps to Test

Expected Results

Additional Context

Required Actions

  • Requires documentation updates
  • Requires downstream repository changes
  • Requires infrastructure/deployment changes
  • Requires coordination with other teams
  • Blocked by PR/MR: #XXX

Screenshots/Logs

Summary by CodeRabbit

  • Bug Fixes
    • Improved database migration reliability by adding a safety check that defers feature flag initialization until all pending migrations are complete, reducing potential errors during migration processes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

Introduces a guard that skips feature flag initialization when database migrations are incomplete. Adds early return logic with debug logging to prevent purge_feature_flags and load_feature_flags execution until migrations are complete. Adds test coverage for this behavior.

Changes

Cohort / File(s) Summary
Migration Guard
ansible_base/feature_flags/utils.py
Adds import for migrations_are_complete and introduces early return guard in create_initial_data that skips feature flag operations when migrations are incomplete, with debug logging.
Test Coverage
test_app/tests/feature_flags/test_utils.py
Adds autouse fixture mock_migrations_complete to ensure migrations are mocked as complete by default. Adds test_create_initial_data_skips_when_migrations_incomplete to verify that purge and load operations are skipped and appropriate debug message is logged when migrations are incomplete.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'AAP-65260: feature flag restore' is a jira ticket reference with minimal descriptive content that doesn't clearly convey the actual change (adding a migration guard to skip feature flag initialization). Consider a more descriptive title like 'Skip feature flag initialization during incomplete migrations' that explains the actual change without relying solely on a ticket reference.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into devel

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

DVCS PR Check Results:

PR appears valid (JIRA key(s) found)

@zkayyali812 zkayyali812 marked this pull request as ready for review February 13, 2026 14:51
@sonarqubecloud
Copy link
Copy Markdown

@zkayyali812 zkayyali812 merged commit 1c31509 into ansible:devel Feb 13, 2026
20 checks passed
@zkayyali812 zkayyali812 deleted the AAP-56260 branch February 13, 2026 15:18
huffmanca pushed a commit to huffmanca/django-ansible-base that referenced this pull request Apr 13, 2026
## Description

Alternativate fix to - ansible#918, with more concise check and corrected log
message

- What is being changed?
Adds logic to block feature flags loading code from running during
partial migrations
- Why is this change needed?
This change is needed to ensure restore flow works reliably
- How does this change address the issue?
This change addresses the issue by adding a guard to ensure that the
feature flags load logic does not run when migrations are incomplete

## Type of Change
<!-- Mandatory: Check one or more boxes that apply -->
- [x] Bug fix (non-breaking change which fixes an issue)

## Self-Review Checklist
<!-- These items help ensure quality - they complement our automated CI
checks -->
- [ ] I have performed a self-review of my code
- [ ] I have added relevant comments to complex code sections
- [ ] I have updated documentation where needed
- [ ] I have considered the security impact of these changes
- [ ] I have considered performance implications
- [ ] I have thought about error handling and edge cases
- [ ] I have tested the changes in my local environment

## Testing Instructions
<!-- Optional for test-only changes. Mandatory for all other changes -->
<!-- Must be detailed enough for reviewers to reproduce -->
### Prerequisites
<!-- List any specific setup required -->

### Steps to Test
1. 
2. 
3. 

### Expected Results
<!-- Describe what should happen after following the steps -->

## Additional Context
<!-- Optional but helpful information -->

### Required Actions
<!-- Check if changes require work in other areas -->
<!-- Remove section if no external actions needed -->
- [ ] Requires documentation updates
  <!-- API docs, feature docs, deployment guides -->
- [ ] Requires downstream repository changes
  <!-- Specify repos: django-ansible-base, eda-server, etc. -->
- [ ] Requires infrastructure/deployment changes
  <!-- CI/CD, installer updates, new services -->
- [ ] Requires coordination with other teams
  <!-- UI team, platform services, infrastructure -->
- [ ] Blocked by PR/MR: #XXX
  <!-- Reference blocking PRs/MRs with brief context -->

### Screenshots/Logs
<!-- Add if relevant to demonstrate the changes -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved database migration reliability by adding a safety check that
defers feature flag initialization until all pending migrations are
complete, reducing potential errors during migration processes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

3 participants