-
Notifications
You must be signed in to change notification settings - Fork 42
Model with binary UUID can't be used in a Laravel Queue payload #22
Comments
@rogatty I would suggest not to provide the model instance to the Job constructor and get the model instance inside the handle() method. For example, SQS has 256kb message limit and model instance can be really large. |
@vadim-nilov in general, I agree. There are times when it makes sense to pass an instance, though. If you do while using this library, you'll have a bad time debugging what's wrong. Hopefully people will search on GitHub and find this issue 🙂 |
Laravel only serializes the model identifier for queueable jobs. So as long as you still have a regular id alongside the uuid on the model (which you should have) you'll be able to pass the model instance to the job. This is the case since L5.0.
|
@robvankeilegom I don't think that's the case. I'm using the normal |
@binaryfire Do you have the |
@robvankeilegom Yeah I do. |
@binaryfire Here's a reproduction repo if you're curious: https://github.com/binaryfire/filament-import-export-bug Log into the Filament dashboard, head to Products and create a couple, then try exporting to CSV. It'll throw the exception. But if you remove the binary uuid column from the User model it works fine. This is the job in question. We've been trying to figure out a workaround but no joy. Might have to remove the binary column and just switch back to string... |
dispatch(new MyJob(ModelWithBinaryUuid::create()))
fails with:This is a know issue documented in laravel/framework#15235 and laravel/framework#12194. Laravel's Queue uses
json_encode()
which doesn't call model'stoJson()
method. Because of that https://github.com/michaeldyrynda/laravel-model-uuid/blob/79b20e5b2d6cae7b64e45858ea9202b7f26975a6/src/GeneratesUuid.php#L167-L175 is not called.I don't have any good ideas how to solve it without modifying the Laravel's Queue code. Would be nice to add a note to docs about it, so people using this package don't have to do the research I did. My workaround will be to not pass the whole model to the Queue but only the attributes I need.
The text was updated successfully, but these errors were encountered: