Clear stale failure detail when an Android profile becomes verified - #50774
Clear stale failure detail when an Android profile becomes verified#50774Dhvanit41 wants to merge 2 commits into
Conversation
verifyDevicePolicy carried the stored detail forward into the payload it upserted, so a profile that had previously failed kept its old error message after it transitioned to verified. The message stayed visible on the host's profile even though nothing was wrong anymore. Set the detail to empty whenever a profile is marked verified, in both the "no non-compliance reported" path and the per-profile path where only some profiles are still non-compliant. Fixes fleetdm#50357
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAndroid MDM profile verification now clears stored failure details when a profile becomes verified. Non-compliant profiles receive refreshed failure details. Regression coverage tests selective status transitions and clearing all details when the device reports full compliance. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/mdm/android/service/pubsub_test.go`:
- Around line 920-922: Update the stillFailingProfile assertion in the relevant
pubsub test to verify that profile.Detail contains the refreshed cameraDisabled
failure message, or at minimum differs from staleDetail, rather than only being
non-empty. Preserve the existing MDMDeliveryFailed status assertion.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f1d8c1ca-1bc0-4c17-82ab-14f5e062ea09
⛔ Files ignored due to path filters (1)
changes/50357-android-profile-stale-failure-detail.mdis excluded by!**/*.md
📒 Files selected for processing (2)
server/mdm/android/service/pubsub.goserver/mdm/android/service/pubsub_test.go
The still-failing profile assertion only checked that Detail was non-empty, so it would also pass if the upsert carried the stale message over. Assert the exact message the current status report builds instead.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #50774 +/- ##
==========================================
- Coverage 68.40% 68.40% -0.01%
==========================================
Files 3963 3963
Lines 255174 255174
Branches 13616 13616
==========================================
- Hits 174555 174554 -1
- Misses 65020 65023 +3
+ Partials 15599 15597 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@georgekarrv this one's ready for a look when you get a chance. Fix for #50357 — Also addressed the CodeRabbit comment in bf2f393 — the still-failing assertion was only checking Let me know if you'd like anything changed. |
Related issue: Resolves #50357
When an Android configuration profile transitioned from
failedback toverified,verifyDevicePolicycopied the storeddetailinto the payload it upserted, so therow kept the old failure message even though the profile was now compliant. The stale
message stayed visible against a verified profile.
This clears
detailwhenever a profile is marked verified, in both paths ofverifyDevicePolicy:that is no longer in
NonComplianceDetailsis verified and must not keep themessage from the previous report).
Profiles that are still non-compliant are unaffected: they continue to be marked
failed with a freshly built message.
The datastore already writes
detail = VALUES(detail)on this path, so passing anempty string clears the column. The
preserveExistingDetailvariant of the upsert —which intentionally keeps a forward-looking detail such as "Waiting for certificate…"
on withheld ONC profiles — uses a different caller and is untouched.
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Added
TestStatusReportPolicyValidation/stale failure detail is cleared once a profile is verified, covering both branches: a profile that becomes compliant while anotherstays non-compliant, and a report with no non-compliance at all.
Verified the test is a genuine regression test — with the fix reverted it fails with
the exact detail string from the issue:
go test ./server/mdm/android/...passes,gofmtandgo vetare clean.Not manually QA'd: reproducing it end to end needs a BYOD Android device that can
trip a
USER_ACTIONnon-compliance and then satisfy it, which I don't have accessto. The unit test reproduces the reported database state instead.
Summary by CodeRabbit
Bug Fixes
Tests