-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[12.x] RequestException: attempt to summarize message before reporting
#57767
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
base: 12.x
Are you sure you want to change the base?
Conversation
|
This will make #57601 and issue again. The handler isn't always resolved on the web request when the exception triggers. |
Yeah. I think what we have to do is attempt to summarize it twice, once upon construction and a second time when report() is called. I didn't dig too deep, is there a reason we can just resolve the exception handler sooner? |
You don't need to have it resolved for every request. As for local/CI environment What about adding |
Sorry, let me rephrase. The problem is that the callback passed to Exceptions@using() doesn't get executed until the ExceptionHandler interface is resolved. Couldn't we just resolve the ExceptionHandler during app boot and revert the changes in the previous MR?
I think that method could make sense, however, what I'm trying to avoid is a breaking change in things like log monitors in observability tools. Such as in a codebase that doesn't leverage edit: I am not proposing that forwarding the exception's message is necessarily the best engineering practice, however, legacy codebases don't always have the luxury of mass refactors to fix those sort of issues in one go. 😅 |
RequestException: attempt to summarize message before reporting
|
I'm honestly so lost on this entire issue. What do I need to do / merge? |
The message summarizing aspect previously did not work if you were using the ApplicationBuilder::withExceptions() to indicate you don't want RequestExceptions truncated, because the ExceptionHandler hadn't been booted. If you had done it the other way, like inside of your AppServiceProvider, it would have worked as expected. In either case, at least a partial summary of the response would be included in the RequestException's message. With the change that went out in the last release, no summary is added to the message UNTIL you call report() (either directly or by the ExceptionHandler doing it's magic). I personally feel this is probably a better approach than just reverting the change, since we now:
|
For applications that were logging the RequestException's error message (but not calling
report()) or who were using$exception->getMessage()in some other way:str_contains($requestException->getMessage(), 'not found')throw new ShippingException($requestException->getMessage(), previous: $requestException)For example, if an application had set
RequestException::dontTruncate()inside of their AppServiceProvider instead of through the callback provided toApplicationBuilder@exceptions(), they would have previously had the body of the response in hand. But now, a separate method needs to be called in order to build the message.Additionally, it's possible a RequestException could be reported twice, and in so doing would build the summary twice.
The benefit to just reverting the change is that we don't need users to update their configuration to use the
ApplicationBuilder@registered()callback instead of how it's been documented. (TheExceptions@dontTruncateRequestExceptions()andExceptions@truncateRequestExceptionsAt()would remain in the code, tho do not function as expected). If the users DO switch to using the new callback described in this docs PR, they'll actually get the full body of the payload even without having to callRequestException@report()The downside here is that when exceptions are reported, they'll generate the summary twice (once upon construction, once upon reporting).