Skip to content

Setting request exception truncating doesn't work on HTTP layer when configured inside app.php #57601

@mnastalski

Description

@mnastalski

Laravel Version

12.36.1

PHP Version

8.3

Database Driver & Version

No response

Description

It's possible to configure truncateRequestExceptionsAt() and dontTruncateRequestExceptions() inside of bootstrap/app.php but neither works when the request is made on the HTTP layer. It does work fine when using CLI however.

Also, if you take the methods called inside either of these functions and call them for example inside of AppServiceProvider::boot() they will work as expected.

Seems to happen on all 12.x versions.

Steps To Reproduce

bootstrap/app.php:

...
->withExceptions(function (Exceptions $exceptions): void {
    $exceptions->dontTruncateRequestExceptions();
})

Create a route that makes a request using the HTTP client:

Route::get('test', function (): void {
    Http::get('https://google.com/test')->throw();
});

Visit said route, truncated exception is shown:

Illuminate\Http\Client\RequestException
vendor\laravel\framework\src\Illuminate\Http\Client\Response.php:316

HTTP request returned status code 404: <!DOCTYPE html> <html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)

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