Mautic Community Forums

HubSpot App - v1.2.4 - Internal Error

Hi Guys,



I updated to version 1.2.4 earlier today and it has broken the HubSpot App / Plugin for me. I’m now receiving the below error when opening the plugin.







Not sure if this is affecting anyone else.



Kind regards,



Nate C.

Hi Guys,

I updated to version 1.2.4 earlier today and it has broken the HubSpot App / Plugin for me. I’m now receiving the below error when opening the plugin.

Not sure if this is affecting anyone else.

Kind regards,

Nate C.

Hi Nate,

Can you check Mautic’s logs to see what is causing the uh oh? It should be listed under System Info -> Logs or you can check app/logs on the filesystem.

Thanks!
Alan

Hi Alan,

Thanks for getting back to me so quickly.

The log states:

[2016-01-26 03:29:42] mautic.NOTICE: PHP Notice: Undefined index: path - in file /opt/bitnami/apps/mautic/htdocs/app/bundles/CoreBundle/Controller/ExceptionController.php - at line 98 [] []
[2016-01-26 03:30:17] mautic.NOTICE: PHP Notice: Undefined index: name - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 99 [] []
[2016-01-26 03:30:17] mautic.NOTICE: PHP Notice: Undefined index: label - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 101 [] []
[2016-01-26 03:30:17] mautic.NOTICE: PHP Notice: Undefined index: label - in file /opt/bitnami/apps/mautic/htdocs/app/bundles/PluginBundle/Form/Type/FieldsType.php - at line 34 [] []
[2016-01-26 03:30:17] mautic.CRITICAL: Uncaught PHP Exception SymfonyComponentFormExceptionLogicException: “A form with an empty name cannot have a parent form.” at /opt/bitnami/apps/mautic/htdocs/vendor/symfony/form/Symfony/Component/Form/Form.php line 272 {“exception”:"[object] (Symfony\Component\Form\Exception\LogicException(code: 0): A form with an empty name cannot have a parent form. at /opt/bitnami/apps/mautic/htdocs/vendor/symfony/form/Symfony/Component/Form/Form.php:272)"} []

Not sure if that is of any use.

kind regards,

Nate C.

Did you by chance change any of your lead fields in Hubspot? Based on that error trail, it seems Hubspot API is returning something that has an empty name and label leading to a bad form field and then the uncaught exception. No clue what’s being returned though.

You can try adding this line of code here https://github.com/mautic/mautic/blob/db0ab91c353e36fbbaf06480f2895904f40e84ee/plugins/MauticCrmBundle/Integration/HubspotIntegration.php#L96

$this->factory->getLogger()->log('error', print_r($leadFields, true));

Open the plugin configuration to trigger the error then check your log to see what was recorded. Create a bug report at https://github.com/mautic/mautic/issues with the errors along with what was recorded by the above change.

Thanks!
Alan

I’ve followed what you suggest above, however, since adding that line of code i can’t get the plugin page to open. If i go directly to the url /s/plugins I get the following:


Error returned:

[2016-01-26 03:56:53] mautic.ERROR: Fatal: Namespace declaration statement has to be the very first statement in the script - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 25 [] []
[2016-01-26 03:57:01] mautic.ERROR: Fatal: Namespace declaration statement has to be the very first statement in the script - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 25 [] []
[2016-01-26 03:57:08] mautic.ERROR: Fatal: Namespace declaration statement has to be the very first statement in the script - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 25 [] []

Nate C.

It kind of reads like maybe something extra was added on accident. Check around and before line 25. Was something accidentally added?

hmm, at the top of the document there was this:

Skip to content
Sign up Sign in
This repository
Search
Explore
Features
Enterprise
Pricing
Watch 83 Star 518 Fork 179 mautic/mautic
Code Issues 278 Pull requests 20 Pulse Graphs
Tree: db0ab91c35 Find file Copy pathmautic/plugins/MauticCrmBundle/Integration/HubspotIntegration.php
db0ab91 on 28 Oct 2015
Gabriel Passarelli Code Review
0 contributors
RawBlameHistory 159 lines (140 sloc) 3.37 KB

<?php /** * @copyright 2014 Mautic Contributors. All rights reserved. * @author Mautic .... I've replaced the document with one from current 1.2.4 download and it's 'fixed' that issue but I'm still getting the server error when opening the HubSpot plugin. Log Code: [2016-01-26 05:11:32] mautic.ERROR: Fatal: syntax error, unexpected 'API' (T_STRING) - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 142 [] [] [2016-01-26 05:12:01] mautic.ERROR: Fatal: Namespace declaration statement has to be the very first statement in the script - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 25 [] [] [2016-01-26 05:14:20] mautic.NOTICE: PHP Notice: Undefined index: name - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 99 [] [] [2016-01-26 05:14:20] mautic.NOTICE: PHP Notice: Undefined index: label - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 101 [] [] [2016-01-26 05:14:20] mautic.NOTICE: PHP Notice: Undefined index: label - in file /opt/bitnami/apps/mautic/htdocs/app/bundles/PluginBundle/Form/Type/FieldsType.php - at line 34 [] [] [2016-01-26 05:14:20] mautic.CRITICAL: Uncaught PHP Exception SymfonyComponentFormExceptionLogicException: "A form with an empty name cannot have a parent form." at /opt/bitnami/apps/mautic/htdocs/vendor/symfony/form/Symfony/Component/Form/Form.php line 272 {"exception":"[object] (Symfony\Component\Form\Exception\LogicException(code: 0): A form with an empty name cannot have a parent form. at /opt/bitnami/apps/mautic/htdocs/vendor/symfony/form/Symfony/Component/Form/Form.php:272)"} []

Yea, looks like something was accidentally copied in. Maybe you copied in the github link I had here? If so, that was just meant to be a reference to where to add the line of code I gave. Open the same file (plugins/MauticCrmBundle/Integration/HubspotIntegration.php) in your Mautic installation and find line 96. Copy and paste into that blank line:

$this->factory->getLogger()->log('error', print_r($leadFields, true));

Then try to repeat the issue and see what’s logged.

I am having the exact same issue. When I click on the hub spot icon, it gives me the same error. I am hoping that there is a solution soon. Thankyou…

Hi, Sorry for the delay, the day job keeps getting in the way >_<

I followed what you said to do Alan and here’s the error log returned.

Nothing inside HubSpot has been updated, it’s using the default, free HubSpot CRM account without any alterations. I’m wondering if the API key I put in had a space at the end?

[2016-01-31 15:41:38] mautic.ERROR: Array ( [error] => Array ( [message] => Keys are not available for this transaction to take place. Please verify your settings then try again. ) ) [] []
[2016-01-31 15:41:38] mautic.NOTICE: PHP Notice: Undefined index: name - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 99 [] []
[2016-01-31 15:41:38] mautic.NOTICE: PHP Notice: Undefined index: label - in file /opt/bitnami/apps/mautic/htdocs/plugins/MauticCrmBundle/Integration/HubspotIntegration.php - at line 101 [] []
[2016-01-31 15:41:38] mautic.NOTICE: PHP Notice: Undefined index: label - in file /opt/bitnami/apps/mautic/htdocs/app/bundles/PluginBundle/Form/Type/FieldsType.php - at line 34 [] []
[2016-01-31 15:41:38] mautic.CRITICAL: Uncaught PHP Exception SymfonyComponentFormExceptionLogicException: “A form with an empty name cannot have a parent form.” at /opt/bitnami/apps/mautic/htdocs/vendor/symfony/form/Symfony/Component/Form/Form.php line 272 {“exception”:"[object] (Symfony\Component\Form\Exception\LogicException(code: 0): A form with an empty name cannot have a parent form. at /opt/bitnami/apps/mautic/htdocs/vendor/symfony/form/Symfony/Component/Form/Form.php:272)"} []

I’ll create a case on GitHub shortly.

Kind regards,

Nate C.

Nevermind, after digging around in Github I found the solution Alan provided to someone else. If you’ve having this issue take a look at the suggestion here.

As a quick summary, you need to revert one of your encryptions helpers. Which can be located here:

/htdocs/app/bundles/CoreBundle/Helper - EncryptionHelper.php

Replaced the entire document with the one linked on the suggestion page. I’ll put it below too.

Kind regards,

Nate C.

Previously version of EncryptionHelper.php.

<?php /** * @package Mautic * @copyright 2014 Mautic Contributors. All rights reserved. * @author Mautic * @link http://mautic.org * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html * * http://www.warpconduit.net/2013/04/14/highly-secure-data-encryption-decryption-made-easy-with-php-mcrypt-rijndael-256-and-cbc/ */ namespace MauticCoreBundleHelper; use MauticCoreBundleFactoryMauticFactory; class EncryptionHelper { private $key; /** * @param MauticFactory $factory * * @throws RuntimeException if the mcrypt extension is not enabled */ public function __construct(MauticFactory $factory) { // Toss an Exception back if mcrypt is not found if (!extension_loaded('mcrypt')) { throw new RuntimeException($factory->getTranslator()->trans('mautic.core.error.no.mcrypt')); } $this->key = $factory->getParameter('secret_key'); } /** * Returns a 64 character string * * @return string */ static public function generateKey() { return hash('sha256', uniqid(mt_rand(), true)); } /** * Encrypt string * * @param $encrypt * * @return string */ public function encrypt ($encrypt) { $encrypt = serialize($encrypt); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM); $key = pack('H*', $this->key); $mac = hash_hmac('sha256', $encrypt, substr(bin2hex($key), -32)); $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt . $mac, MCRYPT_MODE_CBC, $iv); $encoded = base64_encode($passcrypt) . '|' . base64_encode($iv); return $encoded; } /** * Decrypt string * * @param $decrypt * * @return bool|mixed|string */ public function decrypt ($decrypt) { $decrypt = explode('|', $decrypt . '|'); $decoded = base64_decode($decrypt[0]); $iv = base64_decode($decrypt[1]); if (strlen($iv) !== mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC)) { return false; } $key = pack('H*', $this->key); $decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $decoded, MCRYPT_MODE_CBC, $iv)); $mac = substr($decrypted, -64); $decrypted = substr($decrypted, 0, -64); $calcmac = hash_hmac('sha256', $decrypted, substr(bin2hex($key), -32)); if ($calcmac !== $mac) { return false; } $decrypted = unserialize($decrypted); return $decrypted; } }