Clear stale broken label rows on profile batch upsert - #44847
Conversation
When a label referenced by an MDM configuration profile was deleted, mdm_configuration_profile_labels.label_id was set to NULL via the FK ON DELETE SET NULL. The cleanup DELETE in batchSetProfileLabelAssociationsDB used `(profile_uuid, label_id) NOT IN (...)`, which under MySQL three-valued logic evaluates to NULL for rows with label_id IS NULL — so broken rows survived every subsequent gitops apply. generateEntitiesToRemoveQuery treats any profile with a NULL label_id row as broken and refuses to schedule its removal from hosts. Result: profiles stayed enforced on previously-targeted hosts regardless of updated YAML targeting. Also clear rows with label_id IS NULL for profiles in the current batch. The safety net for the in-between window (label deleted out-of-band, no batch-set yet) still works since the cleanup only runs when the user explicitly sets a profile's label associations.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe changes fix an issue where stale broken label associations were not being cleared when batch-setting MDM profiles. The deletion logic in 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #44847 +/- ##
==========================================
+ Coverage 66.68% 66.70% +0.01%
==========================================
Files 2665 2667 +2
Lines 214783 215275 +492
Branches 9759 9759
==========================================
+ Hits 143227 143589 +362
- Misses 58521 58613 +92
- Partials 13035 13073 +38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Related issue: Resolves #42637
Checklist for submitter
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Added/updated automated tests
QA'd all new/changed functionality manually
Reproduction steps:
label_idto NULL.Testing steps
Summary by CodeRabbit
Bug Fixes