Skip to content

New release - HOTFIX PCI Project already used voucher#22298

Open
github-actions[bot] wants to merge 2 commits intomasterfrom
release/pci-project-hotfix-voucher
Open

New release - HOTFIX PCI Project already used voucher#22298
github-actions[bot] wants to merge 2 commits intomasterfrom
release/pci-project-hotfix-voucher

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Feb 14, 2026

📦 New release

Approximate release date: 📆

🐛 Bug Fixes

FabienHenon and others added 2 commits February 13, 2026 17:52
ref: #MANAGER-20907

Signed-off-by: Fabien Henon <fabien.henon.ext@corp.ovh.com>
fix(pci-project): already used voucher on activation
@FabienHenon FabienHenon changed the title New release New release - HOTFIX PCI Project already used voucher Feb 14, 2026
@FabienHenon FabienHenon marked this pull request as ready for review February 14, 2026 07:21
@FabienHenon FabienHenon requested a review from a team as a code owner February 14, 2026 07:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request attempts to fix an issue where vouchers are being claimed multiple times during PCI project activation. The fix introduces a check to verify if a voucher has already been used before attempting to claim it again.

Changes:

  • Added isVoucherUsed function to check if a voucher has already been claimed for a project
  • Modified project activation flow to check voucher usage before claiming

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/manager/apps/pci-project/src/data/api/credit.ts Added isVoucherUsed function to determine if a voucher has been applied to a project
packages/manager/apps/pci-project/src/pages/detail/activate/hooks/useActivateProject.tsx Integrated voucher usage check before claiming discovery voucher during project activation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return (
(response.data || []).filter((creditDetail: CreditDetailsResponse) => {
return creditDetail.voucher === voucher;
}).length === 0
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic in isVoucherUsed is inverted. The function returns true when the filter finds no matching vouchers (length === 0), but it should return true when a matching voucher IS found (length > 0).

Currently: Returns true when voucher is NOT in credit details (indicating it hasn't been used)
Expected: Should return true when voucher IS in credit details (indicating it has been used)

This will cause the voucher to be claimed when it has already been used, which is the opposite of the intended behavior. The condition should be length > 0 instead of length === 0.

Suggested change
}).length === 0
}).length > 0

Copilot uses AI. Check for mistakes.
return (
(response.data || []).filter((creditDetail: CreditDetailsResponse) => {
return creditDetail.voucher === voucher;
}).length === 0
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new isVoucherUsed function lacks test coverage. Since the codebase has comprehensive test coverage for other functions in the credit API (see Credit.spec.ts), this new function should also have tests to verify its behavior, especially given the complexity of the logic and the critical nature of preventing duplicate voucher claims.

Suggested change
}).length === 0
}).length > 0

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +46
return (
(response.data || []).filter((creditDetail: CreditDetailsResponse) => {
return creditDetail.voucher === voucher;
}).length === 0
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter callback can be simplified. Instead of an explicit return statement in the filter, you can use an implicit return. The entire logic could also be rewritten more clearly using .some() instead of .filter().length === 0. For example: !response.data?.some(credit => credit.voucher === voucher) which would be more idiomatic. Note: This suggestion assumes the logic bug in the previous comment is fixed first.

Suggested change
return (
(response.data || []).filter((creditDetail: CreditDetailsResponse) => {
return creditDetail.voucher === voucher;
}).length === 0
return !response.data?.some(
(creditDetail: CreditDetailsResponse) => creditDetail.voucher === voucher,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant