Stop logging aggregated GraphQL client input errors as server errors - #41141
Open
lbajsarowicz wants to merge 1 commit into
Open
Stop logging aggregated GraphQL client input errors as server errors#41141lbajsarowicz wants to merge 1 commit into
lbajsarowicz wants to merge 1 commit into
Conversation
ErrorHandler suppresses logging for errors caused by invalid client input, but the aggregate branch logged every child error of an AggregateExceptionInterface directly, so a GraphQlInputException carrying child errors was logged while the same exception without them was suppressed. The suppression decision is now made once per error and applied to both logging calls; the formatted response is unchanged.
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
Contributor
Author
|
@magento run all tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Magento\Framework\GraphQl\Query\ErrorHandlerintentionally does not log GraphQL errors that were caused by invalid client input:log()returned early when the error carriedextensions['category'] === GraphQlInputException::EXCEPTION_CATEGORY.That decision was not honoured for aggregate exceptions.
GraphQlInputExceptionimplementsAggregateExceptionInterface, so it can carry child errors added throughaddError(). When it does,handle()logged every child error with$this->logger->error($aggregatedError)directly, bypassing the suppression that had just been applied to the parent error.The result is inconsistent by the shape of the exception rather than by its cause: a
GraphQlInputExceptionwithout child errors is suppressed, while the very same exception with child errors is written to the exception log at ERROR level. Mutations that report user errors this way — and bots probing the endpoint with invalid input — produce continuous ERROR noise for requests the server correctly rejected as client errors.The suppression decision is now computed once per error and applied to both logging calls. Errors that are not client input errors keep being logged exactly as before, including their aggregated child errors.
The formatted response is unchanged. Every error that was formatted before is still formatted, in the same order — only the logging is affected.
Related Issues
Related to #34973 (broader request to keep client-safe GraphQL exceptions out of the exception log). This PR fixes only the narrow inconsistency inside
ErrorHandlerdescribed above and does not change how any other exception category is logged.Manual testing scenarios
GraphQlInputExceptionthat carries child errors added viaaddError().var/log/exception.log(or the configured exception handler) contains one ERROR entry per child error.Magento\Framework\Exception\InputExceptionwith child errors) and confirm the parent and each child error are still logged.Contribution checklist
Magento\Framework\GraphQl\Test\Unit\Query\ErrorHandlerTest, including a case proving non-client aggregates are still logged)