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

implode() method error after updating to the lates version #1298

Closed
vcaraseni opened this issue Aug 8, 2023 · 3 comments · Fixed by #1299
Closed

implode() method error after updating to the lates version #1298

vcaraseni opened this issue Aug 8, 2023 · 3 comments · Fixed by #1299
Labels

Comments

@vcaraseni
Copy link

vcaraseni commented Aug 8, 2023

Horizon Version

1.19.0

Laravel Version

10.16.1

PHP Version

8.1.11

Redis Driver

PhpRedis

Redis Version

6.2.12

Database Driver & Version

No response

Description

After upgrading Horizon package to the latest version (1.19.0) I started getting errors on /horizon/dashboard route. I checked the documentation to upgrade and used php artisan vendor:publish --tag=laravel-assets --ansi --force which didn't help me. I tried to create HORIZON_ENV from this discussion which also didn't help me. So I started debugging the error and found that in Laravel\Horizon\Http\Controllers\MasterSupervisorController::36 implode method gets the second parameter as a string which is incorrect.
It works when :
'queue' => implode(',', $value ?? []),
instead of
'queue' => implode(',', $value['queue'] ?? []),
So my question is: is this a bug or have I missed something important that can be probably more realistic? Even if it is a bug then something should be done on it.

P.S. Sorry in advance if didn't (or forget to) put some information which can help to understand the bug.

Steps To Reproduce

Set the APP_ENV=local

  • Upgrade to the latest version (current bug on v5.19.0)
  • Open the main page of Horizon app by /horizon/dashboard
  • Then it calls the /masters endpoint on Horizon app.

The hall stack trace of the error:

{
    "message": "",
    "errorCode": "dsa-0",
    "errors": [],
    "origMessage": "implode(): Argument #2 ($array) must be of type ?array, string given",
    "exception": "TypeError",
    "file": "/app/vendor/laravel/horizon/src/Http/Controllers/MasterSupervisorController.php",
    "line": 36,
    "trace": [
        {
            "file": "/app/vendor/laravel/horizon/src/Http/Controllers/MasterSupervisorController.php",
            "line": 36,
            "function": "implode"
        },
        {
            "function": "Laravel\\Horizon\\Http\\Controllers\\{closure}",
            "class": "Laravel\\Horizon\\Http\\Controllers\\MasterSupervisorController",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php",
            "line": 558,
            "function": "array_map"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Collections/Collection.php",
            "line": 777,
            "function": "map",
            "class": "Illuminate\\Support\\Arr",
            "type": "::"
        },
        {
            "file": "/app/vendor/laravel/horizon/src/Http/Controllers/MasterSupervisorController.php",
            "line": 40,
            "function": "map",
            "class": "Illuminate\\Support\\Collection",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php",
            "line": 236,
            "function": "Laravel\\Horizon\\Http\\Controllers\\{closure}",
            "class": "Laravel\\Horizon\\Http\\Controllers\\MasterSupervisorController",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/horizon/src/Http/Controllers/MasterSupervisorController.php",
            "line": 44,
            "function": "each",
            "class": "Illuminate\\Support\\Collection",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
            "line": 54,
            "function": "index",
            "class": "Laravel\\Horizon\\Http\\Controllers\\MasterSupervisorController",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
            "line": 43,
            "function": "callAction",
            "class": "Illuminate\\Routing\\Controller",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
            "line": 260,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\ControllerDispatcher",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
            "line": 205,
            "function": "runController",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 799,
            "function": "run",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 141,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/horizon/src/Http/Middleware/Authenticate.php",
            "line": 18,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 180,
            "function": "handle",
            "class": "Laravel\\Horizon\\Http\\Middleware\\Authenticate",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 116,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 800,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 777,
            "function": "runRouteWithinStack",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 741,
            "function": "runRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 730,
            "function": "dispatchToRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 200,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 141,
            "function": "Illuminate\\Foundation\\Http\\{closure}",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "/app/vendor/helium10/laravel-components/src/CommonMiddlewares/LogContextMiddleware.php",
            "line": 26,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 180,
            "function": "handle",
            "class": "Helium10\\LaravelComponents\\CommonMiddlewares\\LogContextMiddleware",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
            "line": 21,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php",
            "line": 31,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 180,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
            "line": 21,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php",
            "line": 40,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 180,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TrimStrings",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
            "line": 27,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 180,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php",
            "line": 86,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 180,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php",
            "line": 49,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 180,
            "function": "handle",
            "class": "Illuminate\\Http\\Middleware\\HandleCors",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php",
            "line": 39,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 180,
            "function": "handle",
            "class": "Illuminate\\Http\\Middleware\\TrustProxies",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 116,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 175,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 144,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "/app/public/index.php",
            "line": 52,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        }
    ]
}
@nunomaduro
Copy link
Member

cc @PrinsFrank

@PrinsFrank
Copy link
Contributor

PrinsFrank commented Aug 8, 2023

@vcaraseni

Sorry about the inconvenience!
1. Does this error still exist if you shut down the previous running "horizon:work" commands and start new ones after upgrading?
2. Can you provide your config file for horizon? You can redact private information from it, as long as the structure is the same as the one you are running.

I am able to reproduce with a string in the "queue" option for supervisors:

'environments' => [
    'production' => [
        'supervisor-1' => [
            'queue' => 'default'
        ],
    ],
],

I will create a PR in a few seconds!

@vcaraseni
Copy link
Author

Thank you to fast handle this 👍

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

Successfully merging a pull request may close this issue.

4 participants