craft-freeform icon indicating copy to clipboard operation
craft-freeform copied to clipboard

Call to a member function getFormFieldValues() on null in AiBundle.php during form submission

Open robdove opened this issue 1 month ago • 7 comments

What happened?

Issue Summary

After upgrading to Freeform 5.13.3, all form submissions fail with a fatal error in AiBundle.php:78. The error occurs when the spam validation job runs asynchronously and the AI Bundle attempts to access form field values on a null form object.

If I enable "Bypass All Spam Checks for Logged in Users" it submits ok for a logged in user.

Environment

  • Freeform version: 5.13.3
  • Craft CMS version: 4.16.15
  • PHP version: 8.0.2
  • Integrations enabled: None
  • AI integrations configured: None

Form submission fails with the following error:

Exception 'Error' with message 'Call to a member function getFormFieldValues() on null' in /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/Integrations/AI/AiBundle.php:78

Errors and Stack Trace (if available)

Exception 'Error' with message 'Call to a member function getFormFieldValues() on null' in /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/Integrations/AI/AiBundle.php:78

Stack trace:
#0 [internal function]: Solspace\Freeform\Integrations\AI\AiBundle->addAiValuesToJobPostedData(Object(Solspace\Freeform\Events\Integrations\ProcessPostedValuesEvent))
#1 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Array, Object(Solspace\Freeform\Events\Integrations\ProcessPostedValuesEvent))
#2 /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/Jobs/ProcessSpamValidationJob.php(35): yii\base\Event::trigger('Solspace\\Freefo...', 'process-posted-...', Object(Solspace\Freeform\Events\Integrations\ProcessPostedValuesEvent))
#3 /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/Jobs/FreeformQueueHandler.php(48): Solspace\Freeform\Jobs\ProcessSpamValidationJob->execute(Object(craft\queue\Queue))
#4 /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/Integrations/SpamBlocking/SpamBlockingBundle.php(109): Solspace\Freeform\Jobs\FreeformQueueHandler->queueJob(Object(Solspace\Freeform\Jobs\ProcessSpamValidationJob), 200, false)
#5 [internal function]: Solspace\Freeform\Integrations\SpamBlocking\SpamBlockingBundle->validateAsync(Object(Solspace\Freeform\Events\Forms\SubmitEvent))
#6 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Array, Object(Solspace\Freeform\Events\Forms\SubmitEvent))
#7 /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/Services/SubmissionsService.php(219): yii\base\Event::trigger('Solspace\\Freefo...', 'after-submit', Object(Solspace\Freeform\Events\Forms\SubmitEvent))
#8 /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/controllers/SubmitController.php(47): Solspace\Freeform\Services\SubmissionsService->handleSubmission(Object(Solspace\Freeform\Form\Types\Regular))
#9 [internal function]: Solspace\Freeform\controllers\SubmitController->actionIndex()
#10 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#12 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('', Array)
#13 /var/www/html/vendor/craftcms/cms/src/web/Application.php(349): yii\base\Module->runAction('freeform/submit', Array)
#14 /var/www/html/vendor/craftcms/cms/src/web/Application.php(648): craft\web\Application->runAction('freeform/submit', Array)
#15 /var/www/html/vendor/craftcms/cms/src/web/Application.php(311): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#16 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#17 /var/www/html/web/index.php(12): yii\base\Application->run()
#18 {main}

How can we reproduce this?

  1. Upgrade from Freeform 4.1.28 to 5.13.3
  2. Submit any form (with no AI integrations configured)
  3. Error occurs during async spam validation

Freeform Edition

Pro

Freeform Version

5.13.3

Craft Version

4.16.15

When did this issue start?

  • [ ] Unsure
  • [ ] Fresh install of Freeform
  • [x] After upgrading from older Freeform version
  • [ ] After upgrading from older Craft version
  • [ ] After a change to hosting configuration

Previous Freeform Version

4.1.28

robdove avatar Nov 10 '25 15:11 robdove

Sorry about this @robdove,

We've fixed this in the repo already, and plan to release an update today. 🙂

kjmartens avatar Nov 10 '25 15:11 kjmartens

This should now be resolved in Freeform 5.13.4+ 🙂

kjmartens avatar Nov 11 '25 18:11 kjmartens

Thanks, no longer errors but notifications don't get sent unless I set the form to also save submissions.

robdove avatar Nov 12 '25 12:11 robdove

hi @kjmartens checking in on this one to see if you able to replicate or I need to explore other possibilities. It doesn't seem to matter whether the form is set to ajax or page refresh. The submissions only get sent if the form also saves the data.

robdove avatar Nov 20 '25 14:11 robdove

Sorry @robdove, we'll check into this again now 🙂

kjmartens avatar Nov 20 '25 16:11 kjmartens

@robdove

I'm investigating this now. I couldn't replicate in my first test.

Can I get more info on your form setup so I can replicate locally?

Fields info, notifications info, rules and what you have set in Settings tab.

Use Queue for AI Processing enabled? Use Queue for Email Notifications enabled? Use Queue for Integrations enabled?

Thanks

seandelaney avatar Nov 20 '25 17:11 seandelaney

@robdove

I have found the issue. Fix coming soon.

seandelaney avatar Nov 20 '25 18:11 seandelaney

This should now be resolved in Freeform 5.13.6+ 🙂

kjmartens avatar Nov 27 '25 19:11 kjmartens