magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.57k stars 9.32k forks source link

[GraphQl] GraphQl exceptions are always logged in exception log, although they are normal use exceptions. #34973

Open Hexmage opened 2 years ago

Hexmage commented 2 years ago

Summary (*)

Every exception thrown by the graphql endpoint is logged in the exception log. Even though they are functional exceptions that are used to make the frontend work. Because these exceptions are so common, they fill up the exception.log very fast making finding breaking exceptions a lot more cumbersome. The same scenarios through the regular frontend or the api's would not appear in the exception.log.

Examples (*)

As an example when a customer fails to login because they entered an invalid password, it triggers an exception which is logged in the exception.log.

Proposed solution

Don't automatically log the GraphQl "is client safe" exceptions to the exception.log. Either move this to it's own log and/or add a debug option to the backend.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 2 years ago

Hi @Hexmage. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 2 years ago

Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

cpartica commented 2 years ago

@Hexmage Do these exceptions happen much more than Luma's? is logging just adding to how fast a request can respond? how would we identify all exceptions that are "is client safe"? Why would logging in own logfile be better? I am looking for a 1-2 week dev time solution.

Hexmage commented 2 years ago

@cpartica If a Luma Magento 2 shop is configured correctly, you rarely have an exception log. On a PWA shop its filled with messages like: Customer couldn't log in, product is out of stock, quote is inactive, shipping method is missing. All these messages wouldn't result in exceptions on a Luma store, because they are functional exception instead of breaking exceptions.

The reason I would like it to be logged in a different file is to make the other "real" exceptions in the exception log more visible and easier identifiable.

m2-assistant[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 2 years ago

Hello @Hexmage,

thank you for reporting the issue.

Although I understood the issue and reference, for confirming this issue, we would like to generate some generic exceptions which you are referring to for better understanding of your concern.

Here is what I tried to do on Magento 2.4-develop with GraphQL as per your description example:

Based on the above points, can you please check and help us with reproducing the generic GraphQL exceptions that are getting logged in the exception.log file?

Thanks

Hexmage commented 2 years ago

@engcom-Hotel This is the error I'm receiving when I try to login through graphql.

[2022-07-19 13:38:54] main.ERROR: The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later. {"exception":"[object] (GraphQL\\Error\\Error(code: 0): The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later. at ../application/vendor/webonyx/graphql-php/src/Error/Error.php:174, Magento\\Framework\\GraphQl\\Exception\\GraphQlAuthenticationException(code: 0): The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later. at ../vendor/magento/module-customer-graph-ql/Model/Resolver/GenerateCustomerToken.php:59, Magento\\Framework\\Exception\\AuthenticationException(code: 0): The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later. at ../vendor/magento/module-integration/Model/CustomerTokenService.php:95)"} []
engcom-Hotel commented 2 years ago

Hi @Hexmage,

Thank you for providing this info.

I am able to get this info in debug.log. Now it seems appropriate to log this information in debug.log and not in exception.log. And since it is not getting logged in exception.log so ‘real’ exceptions are visible which you thought is better. So the current flow seems fine.

Now based on this, do you think it should not be logged in the debug.log file as well? And please update which version of Magento you are getting this in the exception.log file? Please check and advise.

Thanks

Hexmage commented 2 years ago

@engcom-Hotel I'm still on 2.4.2 for this particular client. So if it moves to the debug log it's already an improvement.

Honestly I think these exceptions should only be logged in files with a debug config or when the shop is in developer mode. Because it is very rare that you actually want to use them. As an example when the non GraphQl endpoints trigger these exceptions they aren't logged either.

engcom-Hotel commented 2 years ago

Hello @Hexmage,

Thanks for the reply!

For now, we are putting this issue on hold for PO confirmation.

Thanks

engcom-Hotel commented 2 years ago

Hello @Hexmage,

We are moving this ticket as feature request for further processing.

Thanks

Viktorja1 commented 2 years ago

@magento give me 2.4.4 instance

magento-deployment-service[bot] commented 2 years ago

Hi @Viktorja1. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @Viktorja1, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

tmotyl commented 1 year ago

any progress here?

Reno-Axel commented 2 months ago

With this graphql have his own log file, just put in any di.xml file and deploy

<virtualType name="[Vendor]\[Module]\Logger\Logger" type="Monolog\Logger">
     <arguments>
         <argument name="name" xsi:type="string">graphql</argument>
         <argument name="handlers" xsi:type="array">
             <item name="system" xsi:type="object">[Vendor]\[Module]\Logger\Handler</item>
         </argument>
     </arguments>
 </virtualType>
 <virtualType name="[Vendor]\[Module]\Logger\Handler" type="Magento\Framework\Logger\Handler\Base">
     <arguments>
         <argument name="fileName" xsi:type="string">/var/log/graphql.log</argument>
         <argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
     </arguments>
 </virtualType>
 <type name="\Magento\Framework\GraphQl\Query\ErrorHandler">
     <arguments>
         <argument name="logger" xsi:type="object">[Vendor]\[Module]\Logger\Logger</argument>
     </arguments>
 </type>