Error: getWorkflowId() on null

So I’ve just managed to set up farmOS via docker. (mysql database). I’m running into the following error:

Error: Call to a member function getWorkflowId() on null in Drupal\asset\Entity\Asset::getWorkflowId() (line 281 of /opt/drupal/web/profiles/farm/modules/core/asset/src/Entity/Asset.php).

-I’ve created a land asset/area, and I’m going to dashboard->assets->

The website encountered an unexpected error. Try again later.

The full stack trace is:

#0 [internal function]: Drupal\asset\Entity\Asset::getWorkflowId(Object(Drupal\asset\Entity\Asset))
#1 /opt/drupal/web/modules/state_machine/src/Plugin/Field/FieldType/StateItem.php(257): call_user_func(Array, Object(Drupal\asset\Entity\Asset))
#2 /opt/drupal/web/modules/state_machine/src/Plugin/Field/FieldType/StateItem.php(132): Drupal\state_machine\Plugin\Field\FieldType\StateItem->getWorkflow()
#3 /opt/drupal/web/core/lib/Drupal/Core/Field/FieldItemList.php(178): Drupal\state_machine\Plugin\Field\FieldType\StateItem->applyDefaultValue(false)
#4 /opt/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(271): Drupal\Core\Field\FieldItemList->applyDefaultValue()
#5 /opt/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(129): Drupal\Core\Entity\ContentEntityStorageBase->initFieldValues(Object(Drupal\asset\Entity\Asset), Array)
#6 /opt/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(94): Drupal\Core\Entity\ContentEntityStorageBase->doCreate(Array)
#7 /opt/drupal/web/modules/state_machine/src/Plugin/views/filter/State.php(143): Drupal\Core\Entity\ContentEntityStorageBase->create(Array)
#8 /opt/drupal/web/modules/state_machine/src/Plugin/views/filter/State.php(77): Drupal\state_machine\Plugin\views\filter\State->getWorkflows(Object(Drupal\Core\Entity\ContentEntityType), 'status')
#9 /opt/drupal/web/core/modules/views/src/Plugin/views/filter/InOperator.php(183): Drupal\state_machine\Plugin\views\filter\State->getValueOptions()
#10 /opt/drupal/web/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php(1067): Drupal\views\Plugin\views\filter\InOperator->valueForm(Array, Object(Drupal\Core\Form\FormState))
#11 /opt/drupal/web/core/modules/views/src/Form/ViewsExposedForm.php(104): Drupal\views\Plugin\views\filter\FilterPluginBase->buildExposedForm(Array, Object(Drupal\Core\Form\FormState))
#12 [internal function]: Drupal\views\Form\ViewsExposedForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
#13 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array(Array, Array)
#14 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(284): Drupal\Core\Form\FormBuilder->retrieveForm('views_exposed_f...', Object(Drupal\Core\Form\FormState))
#15 /opt/drupal/web/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php(134): Drupal\Core\Form\FormBuilder->buildForm('\\Drupal\\views\\F...', Object(Drupal\Core\Form\FormState))
#16 /opt/drupal/web/core/modules/views/src/ViewExecutable.php(1298): Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->renderExposedForm()
#17 /opt/drupal/web/core/modules/views/src/Plugin/views/display/PathPluginBase.php(393): Drupal\views\ViewExecutable->build()
#18 /opt/drupal/web/core/modules/views/src/Plugin/views/display/Page.php(198): Drupal\views\Plugin\views\display\PathPluginBase->execute()
#19 /opt/drupal/web/core/modules/views/src/ViewExecutable.php(1690): Drupal\views\Plugin\views\display\Page->execute()
#20 /opt/drupal/web/core/modules/views/src/Element/View.php(81): Drupal\views\ViewExecutable->executeDisplay('page_type', Array)
#21 [internal function]: Drupal\views\Element\View::preRenderViewElement(Array)
#22 /opt/drupal/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array(Array, Array)
#23 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#24 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(432): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#25 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
#26 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false)
#27 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#28 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(231): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#29 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#30 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#31 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#32 /opt/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#33 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#34 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#35 /opt/drupal/web/modules/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(54): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#37 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#38 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#39 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#40 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#41 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#42 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#43 /opt/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#44 /opt/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#45 {main}

Yes, I’ve cleared cc.

1 Like

Hi @Skipper - Hmm I’ve seen this error before but it has proved somewhat elusive. It’s usually only happened when custom asset/log types are being used and something goes wrong which causes something invalid to be saved to the database.

Have you been doing anything with custom modules or asset/log types? Or is this a 100% default farmOS installation?

Curious, do you get an error when you try to view your asset data via the API? Try going to /api/asset/land in your browser. If that works, try other types (/api/asset/plant, etc).

Clean install. I had some issues on adding in a custom module before, but wiped the entire install and wiped the database schema - so this was 100% clean. It had thrown an error on install, but carried on happily enough.
I’ve ‘resolved’ it through a 3rd wipe, and only installing the additional included modules (like kml import etc) after the install is done, rather than from the install page. That did the trick.
This wasn’t through the API (and I’ve wiped it now…)

Ah ok! If you happen to have the error that was thrown during install, I would be curious… but either way glad it’s working now!