Skip to content

Conversation

@crynobone
Copy link
Member

fix #57601

ApplicationBuilder::withExceptions($using) method only resolves the $using callback after resolving Illuminate\Foundation\Exceptions\Handler. Therefore, any value set via new RequestException($response) will only consist of resolved prepareMessage() value before Handler.

Using report() method will solve the issue.

After the changes

Default

CleanShot 2025-11-12 at 14 45 14

Using $exceptions->truncateRequestExceptionsAt(5);

CleanShot 2025-11-12 at 14 44 49

Using $exceptions->dontTruncateRequestExceptions();

CleanShot 2025-11-12 at 14 45 24

layer when configured inside `bootstrap/app.php`

fix #57601

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
@crynobone crynobone marked this pull request as ready for review November 12, 2025 11:04
@taylorotwell taylorotwell merged commit e8156d8 into 12.x Nov 12, 2025
67 checks passed
@taylorotwell taylorotwell deleted the 12/issue-57601 branch November 12, 2025 16:45
@cosmastech
Copy link
Contributor

cosmastech commented Nov 12, 2025

This broke a test in our pipeline because the exception message changed.

function demo() {
    try {
        Http::throw()->get('https://laravel.com/does-not-exist');
    } catch (Throwable $e) {
        throw new LaravelWebsiteException($e->getMessage(), previous: $e);
    }
}

//
public function testThisThingFails() {
    try {
        demo();
    } catch (LaravelWebsiteException $e) {
        $this->assertStringContainsString('Laravel', $e->getMessage()); // This fails because the message is just: "HTTP request returned status code 404"
    }
}

Not sure about how much monitoring our product has around these errors in DataDog, but it's probably a BC.

@sebastiaanluca
Copy link
Contributor

sebastiaanluca commented Nov 13, 2025

I agree this seems like a minor breaking change. Our test suite caught it too, the exception message does not contain the summary anymore (the report method is never called).

        Http::fake(['https://api.test' => Http::response($this->getErrorResponse(), SymfonyResponse::HTTP_UNAUTHORIZED)]);

        $this->expectException(RequestException::class);
        $this->expectExceptionCode(SymfonyResponse::HTTP_UNAUTHORIZED);
        $this->expectExceptionMessageMatches($this->getErrorResponse()); // Fails here
Failed asserting that exception message 'HTTP request returned status code 401' matches '{
    "success": false,
    "message": "Something happened"
}
'.

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

Successfully merging this pull request may close these issues.

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

5 participants