Problem/Motivation
ViewModeAccessCheck, FormModeAccessCheck and FieldReuseAccessCheck call $route_match->getRawParameter($bundle_entity_type). For an entity type with a bundle key but no bundle entity type, $bundle_entity_type is NULL, so this throws:
TypeError: Symfony\Component\HttpFoundation\InputBag::get(): Argument #1 ($key) must be of type string, null given
When the base route path has no {bundle}, Field UI's RouteSubscriber sets the bundle default on those routes to an empty string, so the checks reach that call.
Steps to reproduce
- Install the standard profile on 11.4.
composer require drupal/menu_item_fields:1.11.0, enable menu_item_fields and menu_item_fields_ui. This setsfield_ui_base_routeof menu_link_content toentity.menu.collection.- As admin, visit
/admin/structure/menu/display. - Result: 500 with the TypeError above.
These steps work on 11.4.x; menu_item_fields 1.x doesn't install on main, and 2.x sets the bundle default itself. The display overview route these checks run on was added in #3564234.
On main there is no core-only UI reproduction (core entity types without a bundle entity type use {bundle} in their base route). The kernel test in the MR uses entity_test, which has a bundle key but no bundle entity type, and fails on main without the fix.
Proposed resolution
Only read the raw bundle parameter when the entity type has a bundle entity type, in all three access checks. Otherwise fall back to the entity type ID as bundle, as EntityViewDisplayOverviewController and EntityViewDisplayStatusController already do, so enabled non-default view and form modes aren't denied.
Remaining tasks
Review MR !17553.
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A
Generated with the help of an LLM.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3398579-2.patch | 2.11 KB | jessey |
| #2 | InputBag-get-receives-null-and-reports-an-error.patch | 836 bytes | jessey |
Issue fork drupal-3398579
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
Comment #2
jessey commentedComment #3
longwaveWhat did you do to trigger this error message? This feels like an incomplete routing definition somewhere.
Comment #4
cilefen commentedComment #5
gigimaorIn my case, after updating the core version to 10.2.2
In /admin/config/people/accounts
In my case, it is caused by a module that is not supported anymore but is still in use: workflow_field_groups
On this line web/core/lib/Drupal/Core/Routing/RouteMatch.php on line 127 $parameter_name is NULL
Preventing this from happening could be done by patching this line
return $this->parameters->get($parameter_name);
to this
return $this->parameters->get($parameter_name ?? '');
Comment #6
longwaveThe fix should be made in
workflow_field_groups, why is it callinggetRawParameter(NULL)?Comment #8
quietone commentedIt has been over a year and there has been no further discussion. In #6 it was stated is not in core. Therefor, I am closing this issue.
Comment #9
jessey commentedOn Drupal 11.4, Field UI local tasks fatal with:
TypeError: InputBag::get(): Argument #1 ($key) must be of type string, null given in RouteMatch::getRawParameter().
11.4 stores raw route parameters in Symfony InputBag, which requires a string key. 11.3 used ParameterBag, which accepted null.
ViewModeAccessCheck (also FormModeAccessCheck / FieldReuseAccessCheck) does:
$route_match->getRawParameter($entity_type->getBundleEntityType());
For entity types with a bundle key but no bundle entity type (e.g. menu_link_content with field_ui_base_route set by Menu Item Fields UI), getBundleEntityType() is NULL. Visiting Structure → Menus then crashes.
Fix: $entity_type->getBundleEntityType() ?? '' in those three access checks.
Comment #10
ironnuts commentedRe: #9 Good to know but steps to reproduce are still needed. A screenshot(s) or a screencast showing how this is triggered would also help. We need to know if it is a standard profile installation. Any themes that are enabled and being used, any core modules that need to be enabled. Do we need to create a content type and add a field? Any field? Then what?
Comment #11
quietone commentedAs stated this needs steps to reproduce to help determine the cause of the problem.
Comment #14
bceyssensSteps to reproduce on 11.4.11:
composer require drupal/menu_item_fields:1.11.0, then enablemenu_item_fieldsandmenu_item_fields_ui. This setsfield_ui_base_routeofmenu_link_contenttoentity.menu.collection./admin/structure/menu/display.Result: a 500 with
TypeError: Symfony\Component\HttpFoundation\InputBag::get(): Argument #1 ($key) must be of type string, null given, fromViewModeAccessCheck::access().menu_link_contenthas abundlekey but no bundle entity type. Field UI'sRouteSubscribersets thebundledefault of that route to''.ViewModeAccessCheckthen callsgetRawParameter(NULL).FormModeAccessCheckandFieldReuseAccessCheckhave the same code.Menu Item Fields 2.1.1 sets the
bundledefault on the 11.4 overview route, so the error does not show with that version.MR !17553 only reads the raw parameter when the entity type has a bundle entity type, in all three checks. It adds a kernel test with
entity_test, which has a bundle key but no bundle entity type. The test fails without the fix with the same TypeError.Generated with the help of an LLM.
Comment #15
bceyssensComment #16
smustgrave commentedTags still need to be addressed
Please review https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquett... if continuing with the AI submissions.
Comment #17
bceyssens