Skip to content
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

Unexpected localized exceptions when thrown via WebAPI #24660

Closed
ValeSauer opened this issue Sep 19, 2019 · 14 comments
Closed

Unexpected localized exceptions when thrown via WebAPI #24660

ValeSauer opened this issue Sep 19, 2019 · 14 comments
Labels
Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: done Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. stale issue Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@ValeSauer
Copy link

ValeSauer commented Sep 19, 2019

Preconditions (*)

  1. Magento 2.3.2 & 2.3-develop
  2. Change locale of main store to german
  3. Create an integration

Steps to reproduce (*)

Unfortunately I have no idea how to trigger a 500 error via REST API. It usually happens by chance when there are database issues or something similar. However, the following steps could help to reproduce it.

  1. Enforce an exception by calling the REST API, for example too many concurrent product updates will cause a "Database deadlock found when trying to get lock" exception
  2. Until 2.3.1 exception thrown by the REST API were always in english, irrespective of the actual store language. This made it easy to catch errors and for example retry on deadlocks. Since 2.3.2 exceptions are localized even via REST API.

Expected result (*)

  1. "Database deadlock found when trying to get lock" exception message in english

Actual result (*)

  1. "Database deadlock gedetecteerd tijdens het verkrijgen van een lock" for a dutch store or any other language for a store in this language
@m2-assistant
Copy link

m2-assistant bot commented Sep 19, 2019

Hi @ValeSauer. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

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

For more details, please, review the Magento Contributor Assistant documentation.

@ValeSauer do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Sep 19, 2019
@ValeSauer
Copy link
Author

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @ValeSauer. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @ValeSauer, here is your Magento instance.
Admin access: https://i-24660-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@ValeSauer ValeSauer changed the title Exceptions are localized when thrown via WebAPI Unexpected localized exceptions when thrown via WebAPI Sep 19, 2019
@engcom-Charlie engcom-Charlie self-assigned this Sep 20, 2019
@m2-assistant
Copy link

m2-assistant bot commented Sep 20, 2019

Hi @engcom-Charlie. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Charlie engcom-Charlie added Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Sep 20, 2019
@ghost ghost unassigned engcom-Charlie Sep 20, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-20289 were created

Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Sep 20, 2019
@zhartaunik
Copy link
Contributor

The described issue contradicts this one: #19908
Should we really leave WebAPI exceptions in English? And why English? They may be used for showing on the frontend. And I think this is not a good behavior.

@ValeSauer
Copy link
Author

Software usually provides machine readable error codes in addition to human readable error descriptions to avoid this issue.
The Web-API is definitely not only intended to be used by frontend applications, but also by backend integrations such as syncs, imports, exports, so it should consider the requirements of a machine. Even a frontend application might be able to interprete error codes, e.g. to implement a retry-mechanism for deadlocks to improve usability.

A frontend application that requires localized error messages must still contain localizations. So it could also handle the localization of error messages.

I think this code, which is necessary to react on error massages, says it all:

   var apiCall = async function (request_data, retry = 0) {
        try {
            var result = await performApiCall(request_data, retry)
            return result
        } catch (e) {
            if (e && typeof (e) == 'string' && (
                e.indexOf("URL key for specified store already exists.") >= 0 || 
                e.indexOf("URL klíč ve zvoleném obchodě již existuje.") >= 0 || 
                e.indexOf("La clé d’URL pour la boutique existe déjà.") >= 0 || 
                e.indexOf("URL-Schlüssel für angegebenen Store ist bereits vorhanden") >= 0 || 
                e.indexOf("Esiste già una URL key per il negozio specificato.") >= 0 || 
                e.indexOf("URL sleutel voor opgegeven winkel bestaat al.") >= 0 || 
                e.indexOf("Klucz URL dla wybranego sklepu już istnieje.") >= 0 || 
                e.indexOf("Belirtilen mağaza için URL anahtarı zaten var.") >= 0 ||
                e.indexOf("La clave de URL para la tienda especificada ya existe.") >= 0
            ) && retry <= MAXURLRETRIES) {

Therefore I suggest the following approach:

  1. Perfect solution: Additionally to the currently localized, human readable error messages, provide unique machine readable error codes for every error message.
  2. If this is not possible, either switch back to english or make the language of the error messages configurable via backend.

@magento-engcom-team magento-engcom-team added this to Ready for Dev in Community Backlog Mar 24, 2020
@sidolov sidolov added this to Ready for Grooming in Low Priority Backlog Sep 3, 2020
@sidolov sidolov added this to Ready for Development in Low Priority Backlog Sep 24, 2020
@ghost ghost removed this from Ready for Dev in Community Backlog Oct 20, 2020
@ghost ghost removed this from Ready for Development in Low Priority Backlog Oct 20, 2020
@ghost ghost removed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 20, 2020
@sdzhepa sdzhepa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Oct 22, 2020
@gabrieldagama gabrieldagama added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Oct 27, 2020
@ghost ghost added this to Ready for Development in Low Priority Backlog Oct 27, 2020
@ghost ghost removed this from Confirmed in Issue Confirmation and Triage Board Oct 27, 2020
@stale
Copy link

stale bot commented Jan 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale issue label Jan 11, 2021
@stale stale bot closed this as completed Jan 25, 2021
@m2-community-project m2-community-project bot moved this from Ready for Development to Done in Low Priority Backlog Jan 25, 2021
@magento-engcom-team
Copy link
Contributor

Hi @ValeSauer.

Thank you for your report and collaboration!

The related internal Jira ticket MC-24222 was closed as Fixed.

The fix will be available with the upcoming 2.4.3 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Jan 25, 2021
@isxam
Copy link
Contributor

isxam commented Dec 20, 2021

@magento give me 2.4.3 instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@bfontaine
Copy link

This is still an issue and it’s very annoying because you can’t reliably identify errors in a generic way because the exact wording depends on the locale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: done Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. stale issue Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Development

No branches or pull requests

8 participants