magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

The requested store cannot be found caused Validate Hash from Store Switcher get false even the hash equal with signature and input hashData

Open tuyennn opened this issue 4 years ago • 15 comments

Preconditions (*)

  1. Magento 2.4.x
  2. Create 2 stores view

Steps to reproduce (*)

  1. Try to switch Stores from Frontend or you could call it language switcher user interface not admin side.
  2. In specific condition the response time of the site could be more than 5s on load(API on load, or slow connection)

Expected result (*)

  1. Target store could be switched and no error found

Actual result (*)

  1. Target store is switched but found The requested store cannot be found. Please check the request and try again.
  2. Just wonder why https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Store/Model/StoreSwitcher/HashGenerator.php#L109 the condition
time() - $timeStamp <= 5

exist for what?

  1. Possible to increase this number to 50 or a configuration as good

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

  • [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [x] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

tuyennn avatar May 19 '21 09:05 tuyennn

Hi @tuyennn. 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.4-develop instance - upcoming 2.4.x release

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

Please, add a comment to assign the issue: @magento I am working on this


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

: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, please 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] avatar May 19 '21 09:05 m2-assistant[bot]

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

  • [ ] 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.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.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.

m2-assistant[bot] avatar May 27 '21 09:05 m2-assistant[bot]

Hi @tuyennn , I have tried on Magento 2.4 develop but I am able to switch to other stores without facing error .PFA. image

Kindly review your steps to reproduce.

engcom-Alfa avatar May 27 '21 09:05 engcom-Alfa

@engcom-Alfa That's completely a disappointed answer as I mentioned while your page request time is more than 5s by any specific reason. Switch store from the frontend is ok but the dumb error message would shown.

tuyennn avatar May 27 '21 10:05 tuyennn

:white_check_mark: Confirmed by @engcom-Alfa Thank you for verifying the issue. Based on the provided information internal tickets MC-42635 were created

Issue Available: @engcom-Alfa, 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 avatar Jun 15 '21 09:06 magento-engcom-team

HI @tuyennn As per the description, I understood like you are switching between the stores, and hence I have followed below steps to reproduce. Below steps followed as I understood :

  1. Created 2 new stores with new URL local.magento.us and local.magento.eu (where I am local.magento.com is being a default one)
  2. In the Admin > Dashboard page, Tried to change the scopes from one store to another, and it is absolutely working fine.
  3. In fact the new store local configuration with new websites is working fine in the front end.

Kindly elaborate your statement "Try to switch Stores from Frontend" for better understanding. Required a step by step reproducible steps possibly with screen shots and/or screen record. Please try it in the latest Magento version and reply with all the information.

engcom-Alfa avatar Jun 16 '21 10:06 engcom-Alfa

@engcom-Alfa for sure we are talking about store switching or language switcher from frontend(user interface) not admin-side. You could see in the code line I mentioned above, the number 5 is hard coded as while my store has specific condition which a request response could be more than 5s on loading you will see the error message/ The question is why 5 but not 50 or 500? and when the hash value is corrected why we have to add 5s validation here,

tuyennn avatar Jun 16 '21 11:06 tuyennn

Hi @tuyennn,

We tried to reproduce the issue but we are not getting the error , it works as expected. Please find the attached screenshots for reference.

Screenshot 2021-08-25 at 9 08 40 PM Screenshot 2021-08-25 at 9 11 27 PM

Screenshot_1_switch_STORE Screenshot_switchStores

Hence, added the label 'Needs update'.

engcom-Delta avatar Jul 02 '21 09:07 engcom-Delta

@engcom-Delta Of course you cannot replicate it on regular conditions. I mentioned In specific condition the response time of the site could be more than 5s on load(API on load, or slow connection)

tuyennn avatar Jul 05 '21 03:07 tuyennn

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:

  • [ ] 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.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.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.

m2-assistant[bot] avatar Jul 09 '21 09:07 m2-assistant[bot]

Hello @tuyennn,

We have tried to reproduce the issue in Magento 2.4-develop. As per your comment, that on a specific condition, the error has been occurred. So we have added PHP's sleep function and made the script to sleep for 10 seconds. We have made the changes in below file:

https://github.com/magento/magento2/blob/bf4cdad2b1d0436be831c1f5c89c1adc77bfd1fc/app/code/Magento/Store/Model/StoreSwitcher/RedirectDataValidator.php#L51

In this file, there is a constant named "TIMEOUT" set with 5 seconds, which we need to increase may be to resolve the issue.

I am marking this issue as a feature request as this is not a bug, but a feature enhancement.

Thanks

engcom-Hotel avatar Jul 09 '21 09:07 engcom-Hotel

:white_check_mark: Confirmed by @engcom-Hotel Thank you for verifying the issue. Based on the provided information internal tickets MC-42635 were created

Issue Available: @engcom-Hotel, 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 avatar Aug 10 '21 13:08 magento-engcom-team

Hi @tuyennn

I have the same issue.

The Magento supporter can reproduce the issue by going to the checkout/cart page after switching stores.

If the request is greater than the TIMEOUT = 5 => the system will show an error

Screenshot 2024-08-23 at 13 49 32

I changed the TIMEOUT = 50 but I have a new issue in the file.

https://github.com/magento/magento2/blob/bf4cdad2b1d0436be831c1f5c89c1adc77bfd1fc/app/code/Magento/Store/Model/StoreSwitcher/RedirectDataCacheSerializer.php#L83

This here can't get $json data therefore it shows a new exception.

Screenshot 2024-08-23 at 13 59 01

Tuyen, Do you have the same issue?

vbuiendertech avatar Aug 23 '24 07:08 vbuiendertech

@vbuiendertech sorry I no longer follow this, and we abandoned this old project with this issue. But in my case I suggest you to improve your performance as decrease server response < 5s avoid this.

tuyennn avatar Aug 23 '24 07:08 tuyennn

Hi @tuyennn

Thank you for your response.

Yes, I have some customized unShareCart for multi-stores.

Maybe it is the reason for response > 5s.

I will optimize this but I still have an issue can't get $json from $cacheKey if the response < 5s while switching between stores.

I will find a solution to this issue.

Thank you so much.

vbuiendertech avatar Aug 23 '24 08:08 vbuiendertech