Fix duplicate FDE TPM keyslots not getting caught correctly#49459
Fix duplicate FDE TPM keyslots not getting caught correctly#49459dantecatalfamo wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Improves Orbit’s snapd error classification so duplicate (already-present) LUKS recovery keyslot situations are correctly treated as conflicts even when snapd returns the plural “already exist” wording (observed in snapd 2.75), ensuring the add→replace fallback logic triggers reliably.
Changes:
- Broadened
snapdAPIError.isConflict()message matching from"already exists"to"already exist"to cover both singular/plural variants. - Added unit tests covering status-code, kind-based, and message-based conflict detection (including the snapd 2.75 plural message regression).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| orbit/pkg/luks/snapd_client.go | Adjusts conflict detection to match plural “already exist” snapd error wording. |
| orbit/pkg/luks/snapd_client_test.go | Adds test coverage for snapdAPIError.isConflict() regression and related cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // The message check uses "already exist" (no trailing s) as the prefix so | ||
| // it matches both the singular ("key slot X already exists") and the | ||
| // plural ("key slots [...] already exist") wording — snapd 2.75 returns | ||
| // the plural form when a name-only keyslotRef expands to both the | ||
| // system-data and system-save containers, which is exactly our case. |
|
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 (2)
WalkthroughUpdated snapd conflict detection to match messages containing “already exist” while preserving existing status and kind checks. Added table-driven tests covering nil errors, HTTP 409 responses, conflict kinds, singular and plural key-slot messages, authentication failures, and generic bad requests. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #49459 +/- ##
=======================================
Coverage 68.07% 68.07%
=======================================
Files 3882 3882
Lines 246370 246401 +31
Branches 13168 13168
=======================================
+ Hits 167716 167743 +27
+ Misses 63515 63514 -1
- Partials 15139 15144 +5
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:
|
Related issue: Resolves #44428
Unreleased bug from #48452 caught during testing
Summary by CodeRabbit
Bug Fixes
Tests