Undefined Index: function Errors in D9

By mrbagnall | 10 August 2020

In my travels, I came across this error that I did not see a lot of documentation on while googling, so I wanted to share what I had found here. Here is the error I found while working on Probo:

Notice: Undefined index: function in Drupal\Core\Utility\Error::getLastCaller() (line 129 of /var/www/html/web/core/lib/Drupal/Core/Utility/Error.php).
Come to realize this was an issue in my routing table:
probo_admin.build_details: 
  path: '/admin/probo/build/details/{buildId}' 
  defaults:
    _controller: '\Drupal\probo_admin\Controller\ProboAdminProject::viewBuildDetails'
    _title: 'Build Details'
  requirements:
    _permission: 'access probo admin'
The resolution was a mal named controller name. Because this should have been pointing to my build class and not my project class. The fix:
probo_admin.build_details: 
  path: '/admin/probo/build/details/{buildId}' 
  defaults:
    _controller: '\Drupal\probo_admin\Controller\ProboAdminBuild::viewBuildDetails'
    _title: 'Build Details'
  requirements:
    _permission: 'access probo admin'

With the proper class now referenced, clear your cache and things should work as normal. This took me about 90 minutes to figure out so thought it might help someone somewhere along the way. All the best.