{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/20371","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/20371/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/20371/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/20371/events","html_url":"https://github.com/laravel/framework/issues/20371","id":247088289,"number":20371,"title":"[5.4]  The payload is invalid : DecryptException on Session","user":{"login":"rikless","id":2073369,"avatar_url":"https://avatars1.githubusercontent.com/u/2073369?v=4","gravatar_id":"","url":"https://api.github.com/users/rikless","html_url":"https://github.com/rikless","followers_url":"https://api.github.com/users/rikless/followers","following_url":"https://api.github.com/users/rikless/following{/other_user}","gists_url":"https://api.github.com/users/rikless/gists{/gist_id}","starred_url":"https://api.github.com/users/rikless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rikless/subscriptions","organizations_url":"https://api.github.com/users/rikless/orgs","repos_url":"https://api.github.com/users/rikless/repos","events_url":"https://api.github.com/users/rikless/events{/privacy}","received_events_url":"https://api.github.com/users/rikless/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-08-01T14:28:24Z","updated_at":"2017-08-01T14:35:09Z","closed_at":"2017-08-01T14:32:48Z","body":"- Laravel Version: 5.4.*\r\n- PHP Version: 5.6 & 7.1\r\n- Database Driver & Version: Postgresql 9.4 & 9.6\r\n\r\n### Description:\r\nI've upgraded 2 Laravel applications on 5.4 few months ago.\r\n\r\nThose application were created on 5.1, and I've always follow the upgrade guide 1 month after any major release.\r\n\r\nSince 5.4, I often have this kind of error on POST/PUT request :\r\n\r\n```\r\nIlluminate\\Contracts\\Encryption\\DecryptException·The payload is invalid\r\n\r\napp/Http/Middleware/CheckForMaintenanceMode.php:43 App\\Http\\Middleware\\CheckForMaintenanceMode::handle\t\r\n             throw new HttpException(503);\r\n        }\r\n        return $next($request); //line 43\r\n    }\r\n}\r\n\r\n```\r\n\r\nThis is the actual code for this middleware : \r\n\r\n```php\r\nnamespace App\\Http\\Middleware;\r\n\r\nuse Closure;\r\nuse Illuminate\\Foundation\\Application;\r\nuse Symfony\\Component\\HttpKernel\\Exception\\HttpException;\r\n\r\nclass CheckForMaintenanceMode\r\n{\r\n\r\n    /**\r\n     * @var Application\r\n     */\r\n    protected $app;\r\n\r\n    public function __construct(Application $app)\r\n    {\r\n        $this->app = $app;\r\n    }\r\n\r\n    /**\r\n     * Handle an incoming request.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request $request\r\n     * @param  \\Closure $next\r\n     * @return mixed\r\n     * @throws HttpException\r\n     */\r\n    public function handle($request, Closure $next)\r\n    {\r\n        if ($this->app->isDownForMaintenance()&&\r\n            !in_array($request->ip(),])) {\r\n            throw new HttpException(503);\r\n        }\r\n\r\n        if (!is_null($this->app->context->context)\r\n            && $this->app->context->maintenance == true\r\n            && !in_array($request->ip(), [])) {\r\n            throw new HttpException(503);\r\n        }\r\n\r\n        return $next($request);\r\n    }\r\n}\r\n```\r\n\r\n\r\n### Steps To Reproduce:\r\n\r\nOn those applications, there is around 5000 unique users per day. It happened around 300 times in the last 2 months. I've never find a way to reproduce it.\r\nI'm using bugsnag with the last laravel lib version, and this has been introduced with 5.4.\r\n\r\nThere was no server change when this issue appears the first time, and I don't use `encrypt()` or `decrypt()` directly, it's related to the session. The session driver is `file` on both applications.\r\n\r\nI had the issue with php 5.6 on Debian 8, and still have it with php 7.1 on Debian 9. \r\n\r\nThe only one place where this exception is thrown is in the `Encrypter` class, `getJsonPayload() ` method.\r\n\r\n### Middleware configuration:\r\n\r\n```php\r\nprotected $middleware = [\r\n        \\App\\Http\\Middleware\\CheckForMaintenanceMode::class,\r\n        \\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize::class,\r\n        \\App\\Http\\Middleware\\TrimStrings::class,\r\n        \\Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull::class,\r\n    ];\r\n\r\n    /**\r\n     * The application's route middleware groups.\r\n     *\r\n     * @var array\r\n     */\r\n    protected $middlewareGroups = [\r\n        'web' => [\r\n            \r\n            \\App\\Http\\Middleware\\EncryptCookies::class,\r\n            \\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse::class,\r\n            \\Illuminate\\Session\\Middleware\\StartSession::class,\r\n            \\Illuminate\\View\\Middleware\\ShareErrorsFromSession::class,\r\n            \\App\\Http\\Middleware\\VerifyCsrfToken::class,\r\n            \\Illuminate\\Routing\\Middleware\\SubstituteBindings::class,\r\n        ],\r\n\r\n        'api' => [\r\n            'throttle:60,1',\r\n            'bindings',\r\n        ],\r\n    ];\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/319389030","html_url":"https://github.com/laravel/framework/issues/20371#issuecomment-319389030","issue_url":"https://api.github.com/repos/laravel/framework/issues/20371","id":319389030,"user":{"login":"rikless","id":2073369,"avatar_url":"https://avatars1.githubusercontent.com/u/2073369?v=4","gravatar_id":"","url":"https://api.github.com/users/rikless","html_url":"https://github.com/rikless","followers_url":"https://api.github.com/users/rikless/followers","following_url":"https://api.github.com/users/rikless/following{/other_user}","gists_url":"https://api.github.com/users/rikless/gists{/gist_id}","starred_url":"https://api.github.com/users/rikless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rikless/subscriptions","organizations_url":"https://api.github.com/users/rikless/orgs","repos_url":"https://api.github.com/users/rikless/repos","events_url":"https://api.github.com/users/rikless/events{/privacy}","received_events_url":"https://api.github.com/users/rikless/received_events","type":"User","site_admin":false},"created_at":"2017-08-01T14:35:09Z","updated_at":"2017-08-01T14:35:09Z","body":"Don't you consider it's a bug ?"}}
{"actor":{"display_login":"rikless"}}