Skip to content

Getting NotFoundHttpException when calling an action from a job #3536

@bluezombie

Description

@bluezombie
  • Laravel Version: 8.58.0
  • Nova Version: 3.10.0
  • PHP Version: 7.4.22
  • Database Driver & Version: MariaDB, ver 10.2.39
  • Operating System and Version: Debian 10
  • Browser type and version: Safari 14.1.2
  • Reproduction Repository: none

Description:

Since I need all the 'action' machinery around a resource (i.e. logs that are generated associated with a resource) I need to manually dispatch an action from a scheduled job. The job is scheduled to run every minute:

WatchFiles.php
` public function __construct()
{

    //Gather all buckets in the system
    $buckets = Bucket::all();

    foreach($buckets as $bucket){
        
        //Gather all enabled encryptables within the bucket
        $encryptables = Encryptable::where('bucket_id',$bucket->id)
                                    ->where('enabled','1')
                                    ->get();                       
        $collection = Collection::wrap($encryptables);
        $action=new StartEncrypting;
      
        $request = app(ActionRequest::class);
        $request->action = $request->query->set('action', $action->uriKey());
        $fields = $request->resolveFields();
        DispatchAction::forModels($request, $action, 'handle', $collection, $fields);
    }

    dump('Stopped processing ' .$bucket->name . ' bucket');

}`

When worker is up and running (launching "php artisan queue:listen") I get the following exception:
`
Symfony\Component\HttpKernel\Exception\NotFoundHttpException

at vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1113
1109▕ */
1110▕ public function abort($code, $message = '', array $headers = [])
1111▕ {
1112▕ if ($code == 404) {
➜ 1113▕ throw new NotFoundHttpException($message);
1114▕ }
1115▕
1116▕ throw new HttpException($code, $message, null, $headers);
1117▕ }

  +2 vendor frames 

3 nova/src/Http/Requests/InteractsWithResources.php:51
abort_if()

  +1 vendor frames 

5 nova/src/Http/Requests/InteractsWithResources.php:53
tap()`

I would appreciate any suggestions you may have.
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions