fix(product-warranty-switch): Gate warranty enabling only#6686
Conversation
regdocs
commented
Jun 11, 2026
- Fixes "failed to change product warranty" error
Confidence Score: 5/5Safe to merge — the change is a minimal, well-targeted guard insertion with no side effects on the surrounding logic. The added early return correctly isolates the quota check to the enabling-only path, directly fixing the reported error. The four new tests cover the full relevant matrix (enable/disable × quota empty/available × cooldown active/inactive) and all trace cleanly through the updated code path. No files require special attention.
|
| Filename | Overview |
|---|---|
| press/api/site.py | Adds an early return in _check_warranty_restrictions so the quota check is only evaluated when enabling warranty; disabling is correctly allowed once the cooldown passes. |
| press/api/tests/test_site.py | Adds TestCheckWarrantyRestrictions with four tests covering the key enabling/disabling vs quota/cooldown combinations; logic and patching are correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[_check_warranty_restrictions called] --> B{is_new OR is_system_user OR not dedicated plan?}
B -- Yes --> RET1[return — no restriction]
B -- No --> C[is_new_plan_supported = is_product_warranty_enabled_for_plan_]
C --> D{is_current_plan_supported == is_new_plan_supported?}
D -- Yes, no change --> RET2[return — no restriction]
D -- No, plan is changing --> E{get_datetime < next_warranty_change?}
E -- Yes, in cooldown --> ERR1[throw: Cannot change before date]
E -- No, cooldown passed --> F{is_new_plan_supported?}
F -- No, disabling warranty --> RET3[return — always allowed after cooldown]
F -- Yes, enabling warranty --> G{quota available > 0?}
G -- No quota --> ERR2[throw: Quota exhausted]
G -- Has quota --> RET4[return — allowed]
Reviews (1): Last reviewed commit: "fix(product-warranty-switch): Gate warra..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6686 +/- ##
============================================
- Coverage 90.91% 50.55% -40.37%
============================================
Files 117 992 +875
Lines 18085 83523 +65438
Branches 676 526 -150
============================================
+ Hits 16442 42222 +25780
- Misses 1608 41269 +39661
+ Partials 35 32 -3
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:
|
|
@Mergifyio backport master |
✅ Backports have been createdDetails
Cherry-pick of 518365f has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |