verbb / postie

A Craft Commerce shipping calculator plugin.
Other
12 stars 18 forks source link

UPS errors #93

Closed angieherrera closed 1 year ago

angieherrera commented 1 year ago

Describe the bug

I've just started setting up Postie and when I load the shipping page in my checkout flow, I get the following error:

'UPS: API error: “Cannot assign Ups\\Entity\\RateRequest to property verbb\\postie\\events\\ModifyPayloadEvent::$payload of type ?array” /my/path/to/vendor/yiisoft/yii2/BaseYii.php:558'

Steps to reproduce

  1. Set up Postie to use UPS
  2. Load shipping method page in checkout

Craft CMS version

4.2.8

Plugin version

3.0.0

Multi-site?

No

Additional context

This is only on local; haven't tried on staging.

Postie config file (postie.php):

'*' => [
        'pluginName' => 'Postie',
        'applyFreeShipping' => true,
        'displayDebug' => false,
        'displayErrors' => true,
        'enableCaching' => true,
        'hasCpSection' => true,
    ],
    'production' => [
         'displayErrors' => false,
    ],

UPS Settings:

CleanShot 2022-10-21 at 13 59 58

Postie error log has the same error message with no additional info; same with Craft web.log file.

engram-design commented 1 year ago

Fixed in 3.0.1

angieherrera commented 1 year ago

@engram-design sorry to bring this back up but we're still running into this issue using Postie 3.0.1. Here's the full error shown after entering shipping info and clicking on next:

'UPS: API error: “Cannot assign Ups\\Entity\\RateResponse to property verbb\\postie\\events\\ModifyRatesEvent::$response of type ?array” /mypathto.../vendor/yiisoft/yii2/BaseYii.php:558' 'UPS: API error: “Cannot assign Ups\\Entity\\RateResponse to property verbb\\postie\\events\\ModifyRatesEvent::$response of type ?array” /mypathto.../vendor/yiisoft/yii2/BaseYii.php:558'

An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /mypathto.../vendor/yiisoft/yii2/helpers/BaseVarDumper.php on line 38. in /mypathto.../yiisoft/yii2/web/Response.php:368
Stack trace:
#0 /mypathto.../vendor/yiisoft/yii2/web/Response.php(341): yii\web\Response->sendHeaders()
#1 /mypathto.../vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
#2 /mypathto.../vendor/craftcms/cms/src/web/ErrorHandler.php(192): yii\web\ErrorHandler->renderException(Object(yii\web\HeadersAlreadySentException))
#3 /mypathto.../vendor/yiisoft/yii2/base/ErrorHandler.php(152): craft\web\ErrorHandler->renderException(Object(yii\web\HeadersAlreadySentException))
#4 /mypathto.../vendor/craftcms/cms/src/web/ErrorHandler.php(66): yii\base\ErrorHandler->handleException(Object(yii\web\HeadersAlreadySentException))
#5 [internal function]: craft\web\ErrorHandler->handleException(Object(yii\web\HeadersAlreadySentException))
#6 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /mypathto.../vendor/yiisoft/yii2/helpers/BaseVarDumper.php on line 38. in /mypathto.../vendor/yiisoft/yii2/web/Response.php:368
Stack trace:
#0 /mypathto.../vendor/yiisoft/yii2/web/Response.php(341): yii\web\Response->sendHeaders()
#1 /mypathto.../vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#2 /mypathto.../web/index.php(21): yii\base\Application->run()
#3 {main}
engram-design commented 1 year ago

Are you sure you're on the latest version? It's just that as per the error message, it doesn't make sense.

Cannot assign Ups\\Entity\\RateResponse to property verbb\\postie\\events\\ModifyRatesEvent::$response of type ?array as ModifyRatesEvent::$response is no longer a ?array type (it was), it's now mixed. So the error message itself seems to be reporting incorrectly as per the latest craft-4.

https://github.com/verbb/postie/blob/be6d1cc146ce763069fe61ca85e051ec0b74c576/src/events/ModifyRatesEvent.php#L21

If you can confirm?

angieherrera commented 1 year ago

I'm pretty confident it was, but I've updated to 3.0.2 just to be sure. Seems to be back to working. Thanks!

engram-design commented 1 year ago

Glad it's working now!