Skip to content

JS error in console on checkout when recaptcha for checkout/placing order is not enabled #33741

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

Closed
1 of 5 tasks
basvanpoppel opened this issue Aug 10, 2021 · 38 comments
Closed
1 of 5 tasks
Labels
Area: UI Framework Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.3 Indicates original Magento version for the Issue report. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.

Comments

@basvanpoppel
Copy link
Contributor

basvanpoppel commented Aug 10, 2021

Preconditions (*)

  1. Magento 2.4.3
  2. 'Stores > Configuration > Security > Google reCAPTCHA Storefront > Storefront > Enable for Checkout/Placing Order' set to 'No' (that's the default config)

Steps to reproduce (*)

  1. Add a product to cart
  2. Go to checkout
  3. Open element inspector, see the JS error

Expected result (*)

  1. No JS errors on checkout
  2. Besides not wanting to run into errors, I wouldn't expect checkout to load any recaptcha JS when all the recaptcha options are not enabled.

Actual result (*)

  1. Error message from recaptcha JS:
knockout.js:3753 Uncaught TypeError: Unable to process binding "afterRender: function(){return renderReCaptcha() }"
Message: Cannot read property 'rendering' of undefined
    at UiClass.initCaptcha (reCaptcha.js:117)
    at UiClass.renderReCaptcha (reCaptcha.js:182)
    at afterRender (eval at createBindingsStringEvaluator (knockout.js:3221), <anonymous>:3:134)
    at init (after-render.js:17)
    at knockout.js:3730
    at Object.ignore (knockout.js:1563)
    at knockout.js:3729
    at Object.arrayForEach (knockout.js:168)
    at applyBindingsToNodeInternal (knockout.js:3715)
    at applyBindingsToNodeAndDescendantsInternal (knockout.js:3573)

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.
  • 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”.

ps. I think severity should be higher, because any dev working om checkout will spot this, and will be looking for a fix. (I first checked all of my modules, themes and 3rd party modules: it's time consuming.)

@m2-assistant
Copy link

m2-assistant bot commented Aug 10, 2021

Hi @basvanpoppel. 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


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

🕙 You can find the schedule on the Magento Community Calendar page.

📞 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.

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

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

@mrtuvn
Copy link
Contributor

mrtuvn commented Aug 11, 2021

Can you proceed checkout with this js error?

@mrtuvn
Copy link
Contributor

mrtuvn commented Aug 11, 2021

Not actually blocker but turn out even you not enable settings (Set NO) but code base still check it by default

@mrtuvn mrtuvn added the Reported on 2.4.3 Indicates original Magento version for the Issue report. label Aug 11, 2021
@onlinebizsoft
Copy link

bug reported too fast :)

@mrtuvn mrtuvn added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 11, 2021
@magento-engcom-team
Copy link
Contributor

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

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

@mrtuvn mrtuvn added Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. Priority: P3 May be fixed according to the position in the backlog. labels Aug 11, 2021
@mrtuvn
Copy link
Contributor

mrtuvn commented Aug 11, 2021

Hi @basvanpoppel Is P3 priority correct for such case ?

@mrtuvn
Copy link
Contributor

mrtuvn commented Aug 11, 2021

Component: Recaptcha

@basvanpoppel
Copy link
Contributor Author

Hi @mrtuvn I would give it P2: Checkout doesn't break (the recaptcha component isn't used, so the JS error doesn't actually hurt) it's not critical and no work-around is needed, which follows P3 description.

But this is awful for developers working on checkout: I have several custom ui components, layout processors and mixins on any checkout i work on. If there's an issue after upgrading, I will first look at my customisations, then at third party modules, then Magento.

Imagine every dev going through this process after seeing this issue, that's a lot of wasted time - and a lot of unhappy devs.

@basvanpoppel
Copy link
Contributor Author

I'm working on a PR for this.

@mrtuvn mrtuvn added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. and removed Priority: P3 May be fixed according to the position in the backlog. labels Aug 11, 2021
@basvanpoppel basvanpoppel changed the title JS error in console on checkout when if recaptcha for checkout/placing order is not enabled JS error in console on checkout when recaptcha for checkout/placing order is not enabled Aug 11, 2021
@chequille
Copy link

New version new bug. I would sugest to set it P1 or better P -100 !?!?!?!?!
Facing the same probllem and it is ugly to have errors even if they do not break the checkout process.

My opinion
Chequille

@speedupmate
Copy link
Contributor

speedupmate commented Aug 16, 2021

In addition to this:

@speedupmate
Copy link
Contributor

Hi @mrtuvn I would give it P2: Checkout doesn't break (the recaptcha component isn't used, so the JS error doesn't actually hurt) it's not critical and no work-around is needed, which follows P3 description.

@basvanpoppel ? install a clean instance of m2 you can't checkout cause of those issues without reCaptcha configuration being enabled and valid means Magento2 does not work out of the box.

By default if extension is in system and is not configured to be used should mean no assets are included in storefront at all. Aim for this in your PR, thanks.

@dudzio12
Copy link
Member

dudzio12 commented Aug 16, 2021

Fix for the impatient (Magento composer installations).

@basvanpoppel -this implements your suggested PR (magento/security-package#302) changes :)

/patches/composer/github-issue-33741.diff

diff --git a/Block/LayoutProcessor/Checkout/Onepage.php b/Block/LayoutProcessor/Checkout/Onepage.php
index 390bf712..b2d5b777 100644
--- a/Block/LayoutProcessor/Checkout/Onepage.php
+++ b/Block/LayoutProcessor/Checkout/Onepage.php
@@ -79,7 +79,8 @@ class Onepage implements LayoutProcessorInterface
             ['place-order-recaptcha']['settings'] = $this->captchaUiConfigResolver->get($key);
         } else {
             if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
-                ['payment']['children']['beforeMethods']['children']['place-order-recaptcha'])) {
+                ['payment']['children']['beforeMethods']['children']['place-order-recaptcha-container']['children']
+                ['place-order-recaptcha'])) {
                 unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
                     ['payment']['children']['beforeMethods']['children']['place-order-recaptcha-container']
                     ['children']['place-order-recaptcha']);
@@ -89,3 +90,4 @@ class Onepage implements LayoutProcessorInterface
         return $jsLayout;
     }
 }
+

/composer.json

{
(...)
    "extra": {
        (...)
        "patches": {
            (...)
            "magento/module-re-captcha-checkout": {
                "Fixed checkout reCaptcha disabling #33741": "patches/composer/github-issue-33741.diff"
            }
        }
    }
}

@speedupmate
Copy link
Contributor

speedupmate commented Aug 16, 2021

@basvanpoppel @dudzio12 although good effort it does not free you from all the loaded reCaptcha mixins defined in following files, those will still wrap what they wrap enabled/disabled layout nodes included or not

vendor/magento/module-re-captcha-paypal/view/frontend/requirejs-config.js 
vendor/magento/module-re-captcha-webapi-ui/view/frontend/requirejs-config.js
vendor/magento/module-re-captcha-frontend-ui/view/frontend/requirejs-config.js
vendor/magento/module-re-captcha-checkout/view/frontend/requirejs-config.js

it mostly means that even if recaptchas are not used your default behaviour is wrapped and no other module tests for those wrapped conditions and mostly assume that defaults are used

@dudzio12
Copy link
Member

@basvanpoppel That's understandable of course, I needed patch to kickstart my project's upgrades, so it is what it is.

I'm still looking forward for you to complete the PR :)

Then I will prepare another patch to fix the issue.

@mrtuvn What is the politics on P2 bug fixes? It will be released as separate patch, next patch release -p1 or in the next minor release?

@mrtuvn
Copy link
Contributor

mrtuvn commented Aug 16, 2021

p2 label is lower priority than p1/p0. It's depend on specific case of ticket. It's not related with fix order deliver to next release. i'm not sure magento team will deliver this fixes as patch (seperate) or regular fix as normal.
I saw a pull request related in the case owner disabled captcha from backend but captcha js files still request from server. But we already have PR for that here
Put here for anyone interesting #33200.
In this specific issue imho captcha js should only available if user put both user/key pair value in backend

@basvanpoppel
Copy link
Contributor Author

basvanpoppel commented Aug 17, 2021

@mrtuvn this issue still has 'ready for dev' status, while this pr should be in the review process, I think: magento/security-package#302

@speedupmate This PR just fixes this specific issue. Preventing other modules from adding wrappers isn't my goal here. If you know of a better way to fix this issue, please share it.

@speedupmate
Copy link
Contributor

@speedupmate This PR just fixes this specific issue. Preventing other modules from adding wrappers isn't my goal here. If you know of a better way to fix this issue, please share it.

Part of this is the layoutprocessor style config you are trying to add but with a plugin to requirejs-config collection class to just exclude non-configured extension files on matching conditions (like enabled/disabled , auth failing etc).

Even better would be stopping popularising mixins as a main go to weapon in devdocs for editing/wrapping component functionality as this is really a sledgehammer that affects wider scope than usual extension tries to cover.

@hostep
Copy link
Contributor

hostep commented Sep 23, 2021

@chittima: could you leave some more detailed info please? Like providing commits that fixed this. Just closing an issue with so little explanation is a bit rude ...
Also: have you tested this while magento/security-package was installed? The comments above seem to indicate that the bug is part of that package.

@sdzhepa
Copy link
Contributor

sdzhepa commented Sep 23, 2021

Hello @hostep @mrtuvn @glevhen

Let me try to shade more lite on the issue based on communication and collaboration in the internal Jira ticket.

  • recently Jira ticket related to this public report was taken into the sprint scope by one of the internal teams
  • But on the initial phase, a QA engineer was not able to reproduce this issue on the latest 2.4-develop branch with security-package installed
  • also issue cannot be reproduced on the 2.4.3-p1

Based on such verification, the ticket was closed by QA with the resolution "cannot reproduce" - according to workflow.
It looks like the problem was already fixed in the scope of some other PRs/commits/tasks etc.

If you still experience a similar issue on the latest version of code I would recommend opening a new issue with updated versions/steps and actual/expected results

@chequille
Copy link

Unbelievable !!!!
we need the information what is finally be done to fix this issue.
We do not want to wait till 2.4.3-p1 is out as it could take a few weeks/months till it is released.

@hostep
Copy link
Contributor

hostep commented Sep 23, 2021

It's actually pretty close, the release of 2.4.3-p1 😉

Thanks @sdzhepa for the extra info, however it would still be nice if somebody could figure out how it got fixed.

@lytesaber
Copy link

Just updated from 2.4.3 to 2.4.3-p1 and still experiencing this error in checkout unless reCAPTCHA is configured.

image

Errors being thrown due to optional configuration not being configured wastes a lot of time. As covered above when updating between versions going through a smashing any log exceptions or console errors thrown post upgrade is standard process and this error in checkout is just another distraction and another pointless issue to investigate. I don't know why errors are seen as acceptable, when the goal should be 0 errors and warnings.

Is there actually going to be a fix put in place for this?

@sdzhepa sdzhepa reopened this Oct 13, 2021
@m2-community-project m2-community-project bot added Progress: ready for dev and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Progress: done labels Oct 13, 2021
@engcom-November
Copy link
Contributor

Verified this issue on Magento 2.4-develop and 2.4.3 versions and the issue is not reproducible on 2.4-develop branch but is reproducible on 2.4.3 version:
image

@sdzhepa
Copy link
Contributor

sdzhepa commented Oct 14, 2021

@engcom-November
Could you please check it on the 2.4.3-p1 release? (it is the lates release)

@sdzhepa
Copy link
Contributor

sdzhepa commented Oct 14, 2021

@engcom-November
Copy link
Contributor

Verified the issue on 2.4.3-p1 version as well and the issue is reproducible:
image

@nicholasscottfish
Copy link

@engcom-November

Do we expect a patch to be released soon?

@nathanjosiah
Copy link
Contributor

nathanjosiah commented Oct 28, 2021

@Kerlitek
Copy link

Kerlitek commented Nov 2, 2021

Just a link for those looking for the actual SOLUTION magento/security-package@d25432d

@jesperingels
Copy link

For anyone looking for a patch on Magento v2.4.3-p1

github-issue-33741.patch

diff --git a/vendor/magento/module-re-captcha-checkout/Block/LayoutProcessor/Checkout/Onepage.php b/vendor/magento/module-re-captcha-checkout/Block/LayoutProcessor/Checkout/Onepage.php
index 3ee2rd..8349152 111644
--- a/vendor/magento/module-re-captcha-checkout/Block/LayoutProcessor/Checkout/Onepage.php
+++ b/vendor/magento/module-re-captcha-checkout/Block/LayoutProcessor/Checkout/Onepage.php
@@ -79,7 +79,8 @@
             ['place-order-recaptcha']['settings'] = $this->captchaUiConfigResolver->get($key);
         } else {
             if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
-                ['payment']['children']['beforeMethods']['children']['place-order-recaptcha'])) {
+                ['payment']['children']['beforeMethods']['children']['place-order-recaptcha-container']['children']
+                ['place-order-recaptcha'])) {
                 unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
                     ['payment']['children']['beforeMethods']['children']['place-order-recaptcha-container']
                     ['children']['place-order-recaptcha']);

@erfanimani
Copy link
Contributor

I would have expected this to be released as a Magento Quality Patch, or is this issue too small for that?

@Aquive
Copy link

Aquive commented Sep 19, 2022

I still have this issue on Magento 2.4.5 It is solved in 2.4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: UI Framework Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.3 Indicates original Magento version for the Issue report. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Archived in project
Development

No branches or pull requests