I have been getting this Error via e-mail with the subject "Store Debug Information", And I can't figure out whats causing it. I know it has something to do with Captcha!

How do you read this error? How can it be fixed?

URL: https://MyDomainDOTcom:443/captcha/refresh/
IP Address:
Time: 2016-05-29 14:28:36 GMT Error:
formId is mandatory
#0 /home/public_html/magento/app/code/core/Mage/Core/Model /Config.php(1354): Mage_Captcha_Model_Zend->__construct(Array)
#1 /home/public_html/magento/app/Mage.php(463): Mage_Core_Model_Config->getModelInstance('captcha/zend', Array)
#2 /home/public_html/magento/app/code/core/Mage/Captcha/Helper/Data.php(72): Mage::getModel('captcha/zend', Array)
#3 /home/public_html/magento/app/code/core/Mage/Captcha/controllers/RefreshController.php(45): Mage_Captcha_Helper_Data->getCaptcha(NULL)
#4 /home/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Captcha_RefreshController->indexAction()
#5 /home/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#6 /home/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#7 /home/public_html/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#8 /home/public_html/magento/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#9 /home/public_html/magento/index.php(91): Mage::run('', 'store')
#10 {main}


The formId is missing from the captcha URL you set in your phtml file. Not sure whether you have included the captch in a custom form. In default forms(customer register, forgot password, login etc), this wont happen unless you override and modified it.

Let me explain how it works in default magento:

In app/code/core/Mage/Captcha/controllers/RefreshController.php

public function indexAction()
    $formId = $this->getRequest()->getPost('formId');
    $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
    $this->getResponse()->setBody(json_encode(array('imgSrc' => $captchaModel->getImgSrc())));
    $this->setFlag('', self::FLAG_NO_POST_DISPATCH, true);

This method need "formId" to be posted when requesting to regenerate the captcha. The formId can be set in the layout xml as below (refer app/design/frontend/base/default/layout/captcha.xml):

    <reference name="customer_form_login">
        <block type="core/text_list" name="form.additional.info">
            <block type="captcha/captcha" name="captcha">
                <reference name="head">
                    <action method="addJs"><file>mage/captcha.js</file></action>
                <action method="setFormId"><formId>user_login</formId></action>
                <action method="setImgWidth"><width>230</width></action>
                <action method="setImgHeight"><width>50</width></action>

The formId should be unique for each action. This helps to validate the captcha.

In your phtml, you need to include the formId as below (refer app/design/frontend/base/default/template/captcha/zend.phtml):

 <script type="text/javascript">//<![CDATA[
    $('<?php echo $this->getFormId() ?>').captcha = new Captcha('<?php echo $this->getRefreshUrl() ?>', '<?php echo $this->getFormId() ?>');

on a different note:

If you are note sure how the emails are reaching your inbox, see below:

In errors/local.xml you can control whether your errors should be printed or emailed.

        <subject>Store Debug Information</subject>
| improve this answer | |
  • @user2774042 Any updates? Did my answer help you? – Nidheesh May 30 '16 at 4:15

Late answer, but In case others come across this, I had this issue come up today too. After investigating, I came across this article (https://www.bemaged.com/en/blog/magento-captcha-error-formid-is-mandatory/) which suggests a bot finding its way to the captcha. I've poppped /captcha/ in my robots.txt. You can actually replicate the error by visiting your website's domain with captcha/refresh/ at the end. You should get an error page and an identical error message. I investigated the IP involved in the error, and I am sure it was not human interaction that caused it. I think if you check your IP logs and cross reference server visitor logs / browser strings and IP reputation, you will find it's not a regular customer/browser and you can probably safely ignore it. If you like, pop a robots.txt rule in for the good obedient bots:

Disallow: /captcha/

If this happens a lot for you and it's definately not your website visitors (I have not tested this, I'm observing my site), follow this suggestion (http://www.pkdavies.co.uk/131-magento-formid-is-mandatory-on-captcha-refresh.html) but don't edit core files! Create a copy of the file "app/code/core/Mage/Captcha/controllers/RefreshController.php" in ""app/code/local/Mage/Captcha/controllers/RefreshController.php" and take it from there. What he suggests is add a check to see if the form ID exists, after line 44 (or there abouts), add:

if (empty($formId)) return false;

This is the first time I've come across this. I'd welcome any comments/edits/updates to this answer.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.