magento2: Magento_ReCaptcha... - Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded
Preconditions (*)
- Update Magento 2.3.5-p2 to magento 2.4.0 or 2.4.1
- PHP 7.4
Actual result (*)
1 exception(s):
Exception #0 (InvalidArgumentException): Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded
Exception #0 (InvalidArgumentException): Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded
<pre>#1 Magento\ReCaptchaCustomer\Plugin\Block\Account\InjectRecaptchaInAuthenticationPopup->afterGetJsLayout(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#000000006bbcd89b000000002441b0fa#, '{"components":{"...') called at [vendor/magento/framework/Interception/Interceptor.php:146]
#2 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#3 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->___callPlugins('getJsLayout', array(), array(array('inject_recaptcha...'))) called at [generated/code/Magento/Customer/Block/Account/AuthenticationPopup/Interceptor.php:26]
#4 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->getJsLayout() called at [vendor/magento/module-customer/view/frontend/templates/account/authentication-popup.phtml:17]
#5 include('/var/www/share/m...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#6 Magento\Framework\View\TemplateEngine\Php->render(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#000000006bbcd89b000000002441b0fa#, '/var/www/share/m...', array('csp' => &Magento\Csp\Api\InlineUtilInterface\Proxy#000000006bbcaa82000000002441b0fa#, 'secureRenderer' => &Magento\Framework\View\Helper\SecureHtmlRenderer\Proxy#000000006bbcd370000000002441b0fa#, 'escaper' => &Magento\Framework\Escaper\Interceptor#000000006bbc91a8000000002441b0fa#)) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#7 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent('render', array(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#000000006bbcd89b000000002441b0fa#, '/var/www/share/m...', array('escaper' => &Magento\Framework\Escaper\Interceptor#000000006bbc91a8000000002441b0fa#))) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#8 Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#000000006bbcd89b000000002441b0fa#, '/var/www/share/m...', array()) called at [app/code/Amasty/Fpc/Plugin/Holepunch/TemplateRenderer.php:58]
#9 Amasty\Fpc\Plugin\Holepunch\TemplateRenderer->aroundRender(&Magento\Framework\View\TemplateEngine\Php\Interceptor#000000006bbca9ae000000002441b0fa#, &Closure#000000006bbcd54b000000002441b0fa#, &Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#000000006bbcd89b000000002441b0fa#, '/var/www/share/m...', array()) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#10 Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#000000006bbcd89b000000002441b0fa#, '/var/www/share/m...', array()) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#11 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins('render', array(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#000000006bbcd89b000000002441b0fa#, '/var/www/share/m...', array()), array(array('Amasty_Base::Add...'))) called at [generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php:26]
#12 Magento\Framework\View\TemplateEngine\Php\Interceptor->render(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#000000006bbcd89b000000002441b0fa#, '/var/www/share/m...', array()) called at [vendor/magento/framework/View/Element/Template.php:273]
#13 Magento\Framework\View\Element\Template->fetchView('/var/www/share/m...') called at [generated/code/Magento/Customer/Block/Account/AuthenticationPopup/Interceptor.php:180]
#14 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->fetchView('/var/www/share/m...') called at [vendor/magento/framework/View/Element/Template.php:303]
#15 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1111]
#16 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1115]
#17 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:675]
#18 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#19 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->___callParent('toHtml', array()) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#20 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#21 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->___callPlugins('toHtml', array(), array(array('inject_plugin'))) called at [generated/code/Magento/Customer/Block/Account/AuthenticationPopup/Interceptor.php:481]
#22 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->toHtml() called at [vendor/magento/framework/View/Layout.php:566]
#23 Magento\Framework\View\Layout->_renderBlock('authentication-p...') called at [vendor/magento/framework/View/Layout.php:542]
#24 Magento\Framework\View\Layout->renderNonCachedElement('authentication-p...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#25 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('authentication-p...') called at [vendor/magento/framework/View/Layout.php:497]
#26 Magento\Framework\View\Layout->renderElement('authentication-p...', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#27 Magento\Framework\View\Layout\Interceptor->renderElement('authentication-p...', false) called at [vendor/magento/framework/View/Layout.php:594]
#28 Magento\Framework\View\Layout->_renderContainer('content', false) called at [vendor/magento/framework/View/Layout.php:544]
#29 Magento\Framework\View\Layout->renderNonCachedElement('content') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#30 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('content') called at [vendor/magento/framework/View/Layout.php:497]
#31 Magento\Framework\View\Layout->renderElement('content', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#32 Magento\Framework\View\Layout\Interceptor->renderElement('content', false) called at [vendor/magento/framework/View/Layout.php:594]
#33 Magento\Framework\View\Layout->_renderContainer('main', false) called at [vendor/magento/framework/View/Layout.php:544]
#34 Magento\Framework\View\Layout->renderNonCachedElement('main') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#35 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main') called at [vendor/magento/framework/View/Layout.php:497]
#36 Magento\Framework\View\Layout->renderElement('main', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#37 Magento\Framework\View\Layout\Interceptor->renderElement('main', false) called at [vendor/magento/framework/View/Layout.php:594]
#38 Magento\Framework\View\Layout->_renderContainer('columns', false) called at [vendor/magento/framework/View/Layout.php:544]
#39 Magento\Framework\View\Layout->renderNonCachedElement('columns') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#40 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('columns') called at [vendor/magento/framework/View/Layout.php:497]
#41 Magento\Framework\View\Layout->renderElement('columns', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#42 Magento\Framework\View\Layout\Interceptor->renderElement('columns', false) called at [vendor/magento/framework/View/Layout.php:594]
#43 Magento\Framework\View\Layout->_renderContainer('main.content', false) called at [vendor/magento/framework/View/Layout.php:544]
#44 Magento\Framework\View\Layout->renderNonCachedElement('main.content') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#45 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main.content') called at [vendor/magento/framework/View/Layout.php:497]
#46 Magento\Framework\View\Layout->renderElement('main.content', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#47 Magento\Framework\View\Layout\Interceptor->renderElement('main.content', false) called at [vendor/magento/framework/View/Layout.php:594]
#48 Magento\Framework\View\Layout->_renderContainer('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:544]
#49 Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#50 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.wrapper') called at [vendor/magento/framework/View/Layout.php:497]
#51 Magento\Framework\View\Layout->renderElement('page.wrapper', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#52 Magento\Framework\View\Layout\Interceptor->renderElement('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:594]
#53 Magento\Framework\View\Layout->_renderContainer('page.wrapper.inn...', false) called at [vendor/magento/framework/View/Layout.php:544]
#54 Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper.inn...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#55 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.wrapper.inn...') called at [vendor/magento/framework/View/Layout.php:497]
#56 Magento\Framework\View\Layout->renderElement('page.wrapper.inn...', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#57 Magento\Framework\View\Layout\Interceptor->renderElement('page.wrapper.inn...', false) called at [vendor/magento/framework/View/Layout.php:594]
#58 Magento\Framework\View\Layout->_renderContainer('wrapper', false) called at [vendor/magento/framework/View/Layout.php:544]
#59 Magento\Framework\View\Layout->renderNonCachedElement('wrapper') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#60 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('wrapper') called at [vendor/magento/framework/View/Layout.php:497]
#61 Magento\Framework\View\Layout->renderElement('wrapper', true) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#62 Magento\Framework\View\Layout\Interceptor->renderElement('wrapper') called at [vendor/magento/framework/View/Layout.php:963]
#63 Magento\Framework\View\Layout->getOutput() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#64 Magento\Framework\View\Layout\Interceptor->___callParent('getOutput', array()) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#65 Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#66 Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', array(), array(array('layout-model-cac...'))) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:494]
#67 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:258]
#68 Magento\Framework\View\Result\Page->render(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [vendor/magento/framework/View/Result/Layout.php:171]
#69 Magento\Framework\View\Result\Layout->renderResult(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#70 Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#71 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [app/code/Amasty/GdprCookie/Plugin/ProcessPageResult.php:57]
#72 Amasty\GdprCookie\Plugin\ProcessPageResult->aroundRenderResult(&Magento\Framework\View\Result\Page\Interceptor#000000006bbc8688000000002441b0fa#, &Closure#000000006bbc931c000000002441b0fa#, &Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#73 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [app/code/Amasty/PageSpeedOptimizer/Plugin/ProcessPageResult.php:40]
#74 Amasty\PageSpeedOptimizer\Plugin\ProcessPageResult->aroundRenderResult(&Magento\Framework\View\Result\Page\Interceptor#000000006bbc8688000000002441b0fa#, &Closure#000000006bbc931c000000002441b0fa#, &Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#75 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [app/code/Magezon/Core/Plugin/View/Result/Layout.php:24]
#76 Magezon\Core\Plugin\View\Result\Layout->aroundRenderResult(&Magento\Framework\View\Result\Page\Interceptor#000000006bbc8688000000002441b0fa#, &Closure#000000006bbc931c000000002441b0fa#, &Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#77 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#78 Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#), NULL) called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130]
#79 Magento\Framework\View\Result\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#000000006bbc979d000000002441b0fa#) called at [vendor/magento/framework/App/Http.php:120]
#80 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#81 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#82 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000006bbc9630000000002441b0fa#) called at [index.php:39]
</pre>
Temporary fix:
php bin/magento module:disable Magento_ReCaptchaAdminUi Magento_ReCaptchaCheckout Magento_ReCaptchaContact Magento_ReCaptchaCustomer Magento_ReCaptchaFrontendUi Magento_ReCaptchaMigration Magento_ReCaptchaNewsletter Magento_ReCaptchaPaypal Magento_ReCaptchaReview Magento_ReCaptchaSendFriend Magento_ReCaptchaUi Magento_ReCaptchaUser Magento_ReCaptchaValidation Magento_ReCaptchaValidationApi Magento_ReCaptchaVersion2Checkbox Magento_ReCaptchaVersion2Invisible Magento_ReCaptchaVersion3Invisible
Attempts at troubleshooting: Vendor folder was completely removed and reloaded via composer:update - no change
Related post: https://magento.stackexchange.com/questions/324266/unable-to-serialize-value-error-malformed-utf-8-characters-possibly-incorrect https://community.magento.com/t5/Magento-2-x-Version-Upgrades/Exception-0-InvalidArgumentException-Unable-to-serialize-value/td-p/459315
Additional info from Engcom
Steps to reproduce:
- Install Magento 2.3.5-p2
- Configure and enable Google reCAPTCHA v3 (this was our case) for Storefront and for Backend under Stores - Configuration - Security
- Add a Language Code, fr for example
- Upgrade Magento to 2.4.1 version. You may use the Guide on How to Upgrade Magento
- After the instance is upgraded, set Magento into Developer Mode
php bin/magento dep:mo:set developer
- Go to Checkout page
Actual Result
1 exception(s):
Exception #0 (InvalidArgumentException): Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded
Exception #0 (InvalidArgumentException): Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded
<pre>#1 Magento\ReCaptchaCustomer\Plugin\Block\Account\InjectRecaptchaInAuthenticationPopup->afterGetJsLayout(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#00000000153132bf000000005a8a438e#, '{"components":{"...') called at [vendor/magento/framework/Interception/Interceptor.php:146]
#2 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#3 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->___callPlugins('getJsLayout', array(), array(array('inject_recaptcha...'))) called at [generated/code/Magento/Customer/Block/Account/AuthenticationPopup/Interceptor.php:23]
#4 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->getJsLayout() called at [vendor/magento/module-customer/view/frontend/templates/account/authentication-popup.phtml:17]
#5 include('/home/chalov/sit...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#6 Magento\Framework\View\TemplateEngine\Php->render(&Magento\Customer\Block\Account\AuthenticationPopup\Interceptor#00000000153132bf000000005a8a438e#, '/home/chalov/sit...', array('csp' => &Magento\Csp\Api\InlineUtilInterface\Proxy#000000001531312a000000005a8a438e#, 'secureRenderer' => &Magento\Framework\View\Helper\SecureHtmlRenderer\Proxy#00000000153125bf000000005a8a438e#, 'escaper' => &Magento\Framework\Escaper#0000000015313228000000005a8a438e#)) called at [vendor/magento/framework/View/Element/Template.php:273]
#7 Magento\Framework\View\Element\Template->fetchView('/home/chalov/sit...') called at [generated/code/Magento/Customer/Block/Account/AuthenticationPopup/Interceptor.php:131]
#8 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->fetchView('/home/chalov/sit...') called at [vendor/magento/framework/View/Element/Template.php:303]
#9 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1111]
#10 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1115]
#11 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:675]
#12 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [generated/code/Magento/Customer/Block/Account/AuthenticationPopup/Interceptor.php:338]
#13 Magento\Customer\Block\Account\AuthenticationPopup\Interceptor->toHtml() called at [vendor/magento/framework/View/Layout.php:566]
#14 Magento\Framework\View\Layout->_renderBlock('authentication-p...') called at [vendor/magento/framework/View/Layout.php:542]
...
#57 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#0000000015313a81000000005a8a438e#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#58 Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#0000000015313a81000000005a8a438e#), array(array('deferJsToFooter', 'result-messages', 'result-builtin-c...', 'result-varnish-c...'))) called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:95]
#59 Magento\Framework\View\Result\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#0000000015313a81000000005a8a438e#) called at [vendor/magento/framework/App/Http.php:120]
#60 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:23]
#61 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#62 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#0000000015313a6c000000005a8a438e#) called at [index.php:39]
</pre>
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 17 (7 by maintainers)
This is due to the MSP_ReCaptcha module storing the public key in plain text (type=“text”), but the Magento recaptcha module stores it encrypted (type=“obscure”). The migration however just copies the plain text value over, so when it is “decrypted”, the resulting value is invalid.
To fix this get the
msp_securitysuite_recaptcha/general/public_key
value from the core_config_data (or your Google ReCaptcha admin page) and run the following commands:The command correctly encrypts the value when adding it to the database.
EDIT: as pointed out by @christianbookpwood below, the command will be different if you are using the recaptcha v3.
This issue comes because recaptcha module configuration values saved in core_config_data table which can’t be serialised.
Fix: Delete only public_key and private_key fields value.
Here are all of the commands I ran to update my settings. Note that this was at the very end of the upgrade process and my site was in maintenance mode at the time:
Just wanted to confirm that I am having this issue after upgrading from 2.3.4 to 2.4.1, and @mattijv’s solution worked for me, with a slight difference, I used the following config keys since I am running Recaptcha v3: