myparcelnl / prestashop

PrestaShop module to integrate with MyParcel NL and BE
https://developer.myparcel.nl/nl/documentatie/11.prestashop.html
10 stars 5 forks source link

Error on receiving shipment_status_change webhook #192

Closed EdieLemoine closed 12 months ago

EdieLemoine commented 2 years ago

Module version

1.7.0

PrestaShop version

1.7.8.7

PHP version

7.3.27

What went wrong?

When an order label does not exist, like when it has been deleted, when receiving a shipment_status_change webhook, an error occurs and triggers a 500 Internal Server Error.

Also occurred with module version 1.6.3

Reproduction steps

  1. Have webhooks and automatic order status based on shipment status set up
  2. Receive shipment_status_change webhook

Relevant log output

Thu Oct 27 13:18:24.544485 2022] [proxy_fcgi:error] [pid ***:tid ***] [client ***] AH01071: Got error 'PHP message: PHP Notice:  Undefined offset: 0 in ***/modules/myparcelnl/src/Model/OrderLabel.php on line 117
PHP message: 
PHP Fatal error: Uncaught TypeError: Return value of OrderLabel::findByLabelId() must be an instance of OrderLabel, null returned in ***/modules/myparcelnl/src/Model/OrderLabel.php:117
Stack trace:
#0 ***/modules/myparcelnl/src/Model/OrderLabel.php(324): OrderLabel::findByLabelId(***)
#1 ***/modules/myparcelnl/src/Entity/OrderStatus/AbstractOrderStatusUpdate.php(62): OrderLabel::setOrderStatus(***, 2)
#2 ***/modules/myparcelnl/src/Entity/OrderStatus/PrintedOrderStatusUpdate.php(27): Gett\\MyparcelNL\\Entity\\OrderStatus\\AbstractOrderStatusUpdate->onExecute()
#3 

Posted data

{
    "data": {
        "hooks": [
            {
                "shipment_id": "***",
                "account_id": "***",
                "shop_id": "***",
                "status": 9,
                "barcode": "3SMYPA***",
                "shipment_reference_identifier": "***",
                "event": "shipment_status_change"
            }
        ]
    }
}

Additional context

No response

arnelap commented 2 years ago

FYI: This happened when the label doesn't exist, presumably was deleted.

EdieLemoine commented 12 months ago

This bug does not occur anymore in v2.0.0-beta.1.

Please read this issue for more information and how to report bugs in the new version.