Skip to content

fix(product-warranty-switch): Gate warranty enabling only#6686

Merged
regdocs merged 1 commit into
developfrom
fix-product-warranty-switch
Jun 11, 2026
Merged

fix(product-warranty-switch): Gate warranty enabling only#6686
regdocs merged 1 commit into
developfrom
fix-product-warranty-switch

Conversation

@regdocs

@regdocs regdocs commented Jun 11, 2026

Copy link
Copy Markdown
Member
  • Fixes "failed to change product warranty" error

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe 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.

Important Files Changed

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]
Loading

Reviews (1): Last reviewed commit: "fix(product-warranty-switch): Gate warra..." | Re-trigger Greptile

@codecov-commenter

codecov-commenter commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.55%. Comparing base (37fb445) to head (518365f).
⚠️ Report is 9 commits behind head on develop.

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     
Flag Coverage Δ
dashboard 62.90% <ø> (-28.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@regdocs regdocs merged commit a807490 into develop Jun 11, 2026
14 checks passed
@regdocs regdocs deleted the fix-product-warranty-switch branch June 11, 2026 08:33
@regdocs

regdocs commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

@Mergifyio backport master

@mergify

mergify Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

backport master

✅ Backports have been created

Details

Cherry-pick of 518365f has failed:

On branch mergify/bp/master/pr-6686
Your branch is up to date with 'origin/master'.

You are currently cherry-picking commit 518365fba.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   press/api/tests/test_site.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   press/api/site.py

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

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.

2 participants