verbb / postie

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

Invalid Configuration – yii\base\InvalidConfigException #142

Closed AndrewMac closed 2 weeks ago

AndrewMac commented 2 weeks ago

Describe the bug

Today I updated to the latest version of Craft Commerce (5.1.0.1), which seemed to go okay. I have a multistore setup, and I used the new Site Settings and propagation features to stop unrelated products appearing in the wrong store. As soon as I did that I got the "Invalid Configuration" error (stack trace below). The front end worked, but the control panel showed that error.

I don't know enough to understand the stack trace, but it did seem to point to Postie. So I disabled Postie—the control panel started working again. I tested by enabling Postie again—the control panel went down again. Disabling Postie once again brought the control panel back to life.

Thanks in advance for any help you can give with this!


Stack trace follows

` yii\base\InvalidConfigException: Invalid owner ID: 33304 in /var/www/html/vendor/craftcms/cms/src/base/NestedElementTrait.php:158 Stack trace:

0 /var/www/html/vendor/craftcms/cms/src/base/NestedElementTrait.php(203): craft\commerce\elements\Variant->getPrimaryOwner()

1 /var/www/html/vendor/craftcms/commerce/src/elements/Variant.php(516): craft\commerce\elements\Variant->getOwner()

2 /var/www/html/vendor/yiisoft/yii2/base/Component.php(139): craft\commerce\elements\Variant->getProduct()

3 /var/www/html/vendor/craftcms/cms/src/base/Element.php(2337): yii\base\Component->__get()

4 /var/www/html/vendor/verbb/postie/src/Postie.php(160): craft\base\Element->__get()

5 /var/www/html/vendor/verbb/postie/src/Postie.php(120): verbb\postie\Postie->getInvalidVariants()

6 /var/www/html/vendor/craftcms/cms/src/web/twig/variables/Cp.php(272): verbb\postie\Postie->getCpNavItem()

7 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1740): craft\web\twig\variables\Cp->nav()

8 /var/www/html/vendor/craftcms/cms/src/helpers/Template.php(148): Twig\Extension\CoreExtension::getAttribute()

9 /var/www/html/storage/runtime/compiled_templates/89/8971d5e1247e050dbb957de7c5c5af0a.php(69): craft\helpers\Template::attribute()

10 /var/www/html/vendor/twig/twig/src/Template.php(398): __TwigTemplate_b5173053ec691d1650597c99cc7bd832->doDisplay()

11 /var/www/html/storage/runtime/compiled_templates/84/84f8d6a3b0dc28130a6661bd242465c2.php(193): Twig\Template->yield()

12 /var/www/html/vendor/twig/twig/src/Template.php(442): __TwigTemplate_ea4afa39073827d344f78a51d96caf2d->block_body()

13 /var/www/html/storage/runtime/compiled_templates/d4/d4a9438ecd0b219a22197f3f7a0b1411.php(105): Twig\Template->yieldBlock()

14 /var/www/html/vendor/twig/twig/src/Template.php(398): __TwigTemplate_3542230c42828a1dbd7b241ad6df4c1f->doDisplay()

15 /var/www/html/storage/runtime/compiled_templates/7a/7a12761b5607de463e108177912c729c.php(61): Twig\Template->yield()

16 /var/www/html/vendor/twig/twig/src/Template.php(398): __TwigTemplate_ae7c44738df31e88661d1c2ed8edfa39->doDisplay()

17 /var/www/html/storage/runtime/compiled_templates/84/84f8d6a3b0dc28130a6661bd242465c2.php(175): Twig\Template->yield()

18 /var/www/html/vendor/twig/twig/src/Template.php(398): __TwigTemplate_ea4afa39073827d344f78a51d96caf2d->doDisplay()

19 /var/www/html/storage/runtime/compiled_templates/f2/f2c70f7b12bee340920b87e2b8162b8e.php(110): Twig\Template->yield()

20 /var/www/html/vendor/twig/twig/src/Template.php(398): __TwigTemplate_e592e2bf26b5344742d139ff6d69ae85->doDisplay()

21 /var/www/html/storage/runtime/compiled_templates/cc/cc2708837358b01aaade59a6f928670b.php(122): Twig\Template->yield()

22 /var/www/html/vendor/twig/twig/src/Template.php(398): __TwigTemplate_8acc515fb66362546fc8fc8703dcc581->doDisplay()

23 /var/www/html/vendor/twig/twig/src/Template.php(354): Twig\Template->yield()

24 /var/www/html/vendor/twig/twig/src/Template.php(369): Twig\Template->display()

25 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render()

26 /var/www/html/vendor/twig/twig/src/Environment.php(306): Twig\TemplateWrapper->render()

27 /var/www/html/vendor/craftcms/cms/src/web/View.php(501): Twig\Environment->render()

28 /var/www/html/vendor/craftcms/cms/src/web/View.php(554): craft\web\View->renderTemplate()

29 /var/www/html/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(57): craft\web\View->renderPageTemplate()

30 /var/www/html/vendor/yiisoft/yii2/web/Response.php(1109): craft\web\TemplateResponseFormatter->format()

31 /var/www/html/vendor/craftcms/cms/src/web/Response.php(339): yii\web\Response->prepare()

32 /var/www/html/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()

33 /var/www/html/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()

34 /var/www/html/web/index.php(12): yii\base\Application->run()

35 {main}

`

Steps to reproduce

Update to latest versions of Craft, Commerce and Postie. It may have to do with multi-store feature?

Craft CMS version

5.4.1

Plugin version

5.0.4

Multi-site?

Yes

Additional context

No response

engram-design commented 2 weeks ago

Hmmm, difficult to say, but looks like there's some sort of issue collating all the "invalid" variants for your site (variants that don't have dimensions and weights). I can't speak to the actual error, and if it's legitimate, but I can certainly handle the Postie side of things by not throwing a fatal error.

Fixed for the next release. To get this early, run composer require verbb/postie:"dev-craft-5 as 5.0.4".

AndrewMac commented 2 weeks ago

Thanks so much! I'm glad you could see what was going on. All I knew was that something somewhere in the Commerce update seemed to have affected Postie and was causing an error. When I get the CO back I will try to get time to go through all the variants and see if anyone missed something important.

AndrewMac commented 2 weeks ago

He @engram-design, I just wanted to say that I managed to isolate the problem to a Product Type that had been set up quite a few versions ago, back in 2019. On my local test site, I deleted all of the products of that type, and I was able to enable Postie again—still the current version, in fact, not your new dev release. But things still go wrong again as soon as I create and add a product of that type. Other product types are fine, so it's something with that one particular type.

Everything had been working fine until the last Commerce update, so I'm not sure what recent change caused the clash with Postie. But I think the best thing for me to do might be to analyse why that particular product type is causing problems. If something in the product type itself is potentially flaky, it might even be better to start from scratch with that range of products and start again. As I investigated I also noticed other strange behaviour with that product type.

So it appears to be something with a faulty product type, and if you think Postie might be better served by putting that error message back then please feel free to do so. Like I said, I'm not at all confident in this product type any more and might end up rebuilding the whole range.

Cheers, Andrew

engram-design commented 2 weeks ago

Thanks for investigating! All my dev version does is add a try/catch around variant querying so if there’s an underlying issue on the Commerce end, it’s not going to fix that.

Sounds like there’s something going on with that product type. I think skipping over the error is fine in Postie as that’s probably not the right place to diagnose the issue, if there is one. It might pay to restart the product type if it’s not too much of a change, just to be safe, but that’ll be your call. If there really is an issue you’d see products of that type throwing errors on the front end with carts and orders.

AndrewMac commented 2 weeks ago

Yep, I think I'll just rebuild them. They're a bit old, as I said, and they've been through several Craft and Commerce updates. If you're happy enough to close this issue, that's fine by me. Thanks for all your help!

engram-design commented 2 weeks ago

Fixed in 5.0.5