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

No query results for model [Spatie\WebhookClient\Models\WebhookCall] #49

Closed
jjba23 opened this issue Mar 4, 2020 · 5 comments
Closed

Comments

@jjba23
Copy link

jjba23 commented Mar 4, 2020

Hello Spatie team, I am using your package and really find it great, works perfectly, thing is when I run it in my MacBook I don't get any issues, but when I deploy to production, some of my webhook calls throw this error, not all of them, that is why I am a bit puzzled, what does this mean? How could I fix it? Missing something?

No query results for model? But my webhook_calls table gets filled and emptied.. How can i find the problem here?

Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model [Spatie\WebhookClient\Models\WebhookCall]. in /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:470

Stack trace:
#0 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(102): Illuminate\Database\Eloquent\Builder->firstOrFail()
#1 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(57): Spatie\WebhookClient\ProcessWebhookJob->restoreModel(Object(Illuminate\Contracts\Database\ModelIdentifier))
#2 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/SerializesModels.php(45): Spatie\WebhookClient\ProcessWebhookJob->getRestoredPropertyValue(Object(Illuminate\Contracts\Database\ModelIdentifier))
#3 [internal function]: Spatie\WebhookClient\ProcessWebhookJob->__wakeup()
#4 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(53): unserialize('O:35:"Infrastru...')
#5 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(88): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#6 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(368): Illuminate\Queue\Jobs\Job->fire()
#7 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(314): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#8 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(134): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#9 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): Illuminate\Queue\Worker->daemon('redis', 'default,priorit...', Object(Illuminate\Queue\WorkerOptions))
#10 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'default,priorit...')
#11 /webstore/api/releases/v-1.1.2/vendor/laravel/horizon/src/Console/WorkCommand.php(46): Illuminate\Queue\Console\WorkCommand->handle()
#12 [internal function]: Laravel\Horizon\Console\WorkCommand->handle()
#13 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#14 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
#15 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#16 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#17 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#18 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\Container\Container->call(Array)
#19 /webstore/api/releases/v-1.1.2/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#20 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#21 /webstore/api/releases/v-1.1.2/vendor/symfony/console/Application.php(1012): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /webstore/api/releases/v-1.1.2/vendor/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(Laravel\Horizon\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /webstore/api/releases/v-1.1.2/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /webstore/api/releases/v-1.1.2/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /webstore/api/releases/v-1.1.2/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 {main}
@spatie-bot
Copy link

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

@zaxn1234
Copy link

zaxn1234 commented Feb 8, 2022

@averageflow I'm having a very similar issue. Same error when deployed (Laravel Vapor with SQS) but runs fine locally (MacBook running Homestead Ubuntu & Redis). Did you get anywhere with this?

@hashimaziz1
Copy link

hashimaziz1 commented Feb 25, 2022

I'm getting this error as a JSON response to my Stripe AJAX fetch while developing on localhost. Anyone have any idea how to fix it? It seems the package is interfering with my Stripe payment element, it's currently not even displaying since I integrated the package via a job.

@EricPaulson
Copy link

After struggling with this for some time, I found that the issue is because of different ways of accessing the payload from the handle() method. Previously, I was accessing the payload like this:

$this->webhookCall['payload'];

But that no longer works in version 3, and will throw the "No query results for model" error. I changed it to this:

$this->webhookCall->payload

And now it works great. Hope this helps someone!

@JasperTey
Copy link

JasperTey commented Dec 4, 2023

I was experiencing the No query results for model [Spatie\WebhookClient\Models\WebhookCall] on a production app with webhooks coming from a 3rd party source (Zoho). The above syntax issues do not apply in my case, since I've been using v3 from the start.

At first, it was hard to troubleshoot because on Zoho's end, I was able to "resend" webhooks - and those resends were processing just fine and I wasn't able to reproduce it.

Eventually I thought it might be related to race conditions and db transactions, because the issue seemed to occur when a stream of consecutive webhooks were received in rapid succession. So I did two things:

  • In the webhook processing Job (which extends ProcessWebhookJob), I added a public $delay = 5;
  • Updated my queue configuration's after_commit to true. I could've also done this at the job-level with public $afterCommit = true;

This appears to have resolved things, at least on an anecdotal level. I would need to write some formal tests to confirm for sure whether the after_commit made a difference.

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

No branches or pull requests

6 participants