Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move string check/decode for data in payload #186

Merged
merged 2 commits into from
Apr 2, 2024
Merged

Conversation

jryd
Copy link
Contributor

@jryd jryd commented Apr 1, 2024

Back towards the end of last year, we reported an issue we were having with the JobRecorder to Flare support. We were experiencing an issue where it seemed that the data payload in our jobs were a string rather than an array.

At the time, this fix was applied to help us with that.

Whilst it seemed to fix the issue at the time, we've seen this issue return:

Cannot access offset of type string on string {"exception":"[object] (TypeError(code: 0): Cannot access offset of type string on string at /home/app/vendor/spatie/laravel-ignition/src/Recorders/JobRecorder/JobRecorder.php:91)

The fix that was applied was inside the foreach loop and would only apply when there was a key in the payload that wasn't being ignored. Evidently, there are times when the payload does not contain any additional keys and so the fix is never applied.

I believe it would make more sense for this to exist outside of the foreach loop so that its always applied whenever the $payload['data'] is a string.

@freekmurze
Copy link
Member

It seems the tests are failing due to the changes in this PR. Could you take a look?

@jryd
Copy link
Contributor Author

jryd commented Apr 2, 2024

Ah, sorry about that!

I've fixed the failing test, it was related to a test for unserializeable payloads.

I tinkered with a couple of different ways to resolve this and settled for a wrapping the if statement in a try/catch, like we've done in other places (which I presume is to handle the unserializeable payloads, amongst other things).

@freekmurze freekmurze merged commit 0c864b3 into spatie:main Apr 2, 2024
29 of 33 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants