Fatal error when trying to add transaction to a non-existing card

Created on 17 March 2025, 2 months ago

Problem/Motivation

When trying to create a Transaction from the Add transaction form and the entered code is not valid, system throws a fatal error WSOD instead of an error indicating that code is not valid:

Error: Call to a member function getBalance() on null in Drupal\commerce_giftcard\Plugin\Validation\Constraint\GiftcardTransactionValidAmountValidator->validate() (line 38 of modules/contrib/commerce_giftcard/src/Plugin/Validation/Constraint/GiftcardTransactionValidAmountValidator.php).

Steps to reproduce

Create a few giftcards
Visit /admin/commerce/giftcards/add-transaction
Enter an invalid giftcard code i nthe autocomplete field
Submit the form
Get the unexpected fatal error instead of just a simple error message.

Proposed resolution

Improve error handling

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇪🇸Spain plopesc Valladolid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024