netgen-layouts / layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.
https://netgen.io/layouts
MIT License
36 stars 6 forks source link

Undefined "method" key while serializing certain exceptions: real exception swallowed #27

Closed weaverryan closed 2 years ago

weaverryan commented 2 years ago

Hi!

While editing a layout, I got this nasty error in an Ajax call:

Screen Shot 2022-08-24 at 3 40 19 PM

What actually happened is that I made a mistake. The page should be showing me this error:

Screen Shot 2022-08-24 at 3 41 06 PM

That's from a mistake in my code. However, it's hidden because ExceptionSerializerListener fails when serializing the exception on this line: https://github.com/netgen-layouts/layouts-core/blob/master/bundles/LayoutsAdminBundle/EventListener/ExceptionSerializerListener.php#L73

The full stack trace is:

Screen Shot 2022-08-24 at 3 42 49 PM

For some reason, when the exception is being serialized, the serialized tries to call getMethod() on RequestDataCollector... $this->data is an empty array at that point, so things explode.

You should be able to repeat the error via this branch - https://github.com/weaverryan/layouts-symfony-barebones/tree/swallowed-error - then create/edit a layout.

Cheers!

emodric commented 2 years ago

Hm, this works fine for me i.e. the original exception is shown, and not the Undefined array key one.

image

Steps taken:

weaverryan commented 2 years ago

I have a new repo to try this on. AND, I think I know why you didn't see the same bad behavior as me. It is all explained in this README: https://github.com/weaverryan/netgens-layouts-playing/tree/exception_swallow

But, in short, when you "trigger" the error (which is from a bug in my code), the layouts admin page breaks (of course) and TWO Ajax requests fail in the background. One of these DOES show the correct error as JSON. The OTHER failed request shows the "bad" undefined array key error from my screenshot.

Cheers!

emodric commented 2 years ago

@weaverryan I still can't reproduce! I indeed get two errors the first time around, but both of them are "normal"

image image

weaverryan commented 2 years ago

Ah, that's crazy! Well, if you still can't replicate it, then I don't think we'll be able to fix it - I can't think of what system differences would cause this (I don't have Xdebug installed... I'm not sure if that could be a difference).

emodric commented 2 years ago

Can you just pack the entire project + DB and send it to me, so I can test that way?

weaverryan commented 2 years ago

As we discussed, that's what the above is - that's the exact code, and even the exact database due to the migrations and fixtures. So, I think it must be triggered by some difference in our php installs/versions? I wouldn't worry about it, until someone else hits the same issue.

emodric commented 2 years ago

Allright!

I'll close this then, feel free to reopen if you have a different reproducer :)