Problem/Motivation

I'm getting the following error when trying to visit /admin/config/people/saml/saml on some builds:

AssertionError: assert($key_type instanceof KeyPluginBase) in assert() (line 164 of modules/contrib/samlauth/src/Form/SamlauthSamlConfigureForm.php).
assert(, 'assert($key_type instanceof KeyPluginBase)') (Line: 164)
Drupal\samlauth\Form\SamlauthSamlConfigureForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('samlauth_configure_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 97)
Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 52)
Drupal\crawler_rate_limit\CrawlerRateLimitMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 116)
Drupal\cloudflare\CloudFlareMiddleware->handle(Object, 1, 1) (Line: 153)
Drupal\redactive_cloudflare\RedactiveCloudFlareMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 49)
Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Strangely, this is happening on my local install but not in our PR environments, even though the code stack should be identical as we're using composer and the same PHP versions, etc... ¯\_(ツ)_/¯

This is fixable by adding the following use statement to the top of SamlauthSamlConfigureForm.php:

use Drupal\key\Plugin\KeyPluginBase;

Steps to reproduce

Attempt to load /admin/config/people/saml/saml

Proposed resolution

Add the use statement; I will open an MR and attach a patch in case anyone else is running into this issue and needs a quick fix :)

/A

Issue fork samlauth-3471040

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexharries created an issue. See original summary.

alexgreyhead’s picture

Title: AssertionError: assert($key_type instanceof KeyPluginBase) in assert() (line 164 of samlauth/src/Form/SamlauthSamlConfigureForm.php) » Error at /admin/config/people/saml/saml: AssertionError: assert($key_type instanceof KeyPluginBase) in assert() (line 164 of samlauth/src/Form/SamlauthSamlConfigureForm.php)
Issue summary: View changes

alexgreyhead’s picture

Patch file in case it's useful to anyone :)

/A

erik.erskine’s picture

Status: Needs review » Needs work
+++ b/src/Form/SamlauthSamlConfigureForm.php
+use Drupal\key\Plugin\KeyPluginBase;

This bit looks good. I had the same problem and came to the same fix.

-      'sp_name_id_format',
+      // DON'T SAVE sp_name_id_format HERE! If it was set to "Custom", this
+      // field will have a value of * and will overwrite the code which
+      // correctly sets the value in src/Form/SamlauthConfigureTrait.php
+      // in setNameID().
+//      'sp_name_id_format',

This bit looks unrelated, perhaps a separate issue?

joelsteidl’s picture

Thanks for the patch @alexharries

Just noting that this solved the used for me as well. I agree with @erik.erskine wondering what purpose the added use statement serves.

  • roderik committed 4dda54ed on 8.x-3.x
    Issue #3471040: Add missing use statement for KeyPluginBase
    
roderik’s picture

Status: Needs work » Fixed

(Oops, forgot names in commit message. But credited while fixing.)

Thanks @alesharries. Again, dumb mistake when refactoring the form.

The unrelated bit is from #3471024: Bug and confusing behaviour when trying to set a custom NameID format which is already known to the module and has been fixed in there / should have been pushed to that PR, instead of this one.

roderik’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.