Problem/Motivation

In #3285496: Update Layout Builder panel size, Patternkit added a link-alter hook to customize links with route "layout_builder.add_block". If that hook tries to process a link without a route, Drupal logs an error like this:

UnexpectedValueException: https://www.drupal.org has no corresponding route. in Drupal\Core\Url->getRouteName() (line 574 of /var/www/web/core/lib/Drupal/Core/Url.php).

Steps to reproduce

- Install Drupal 11.2 with standard profile
- Install Patternkit (latest release 9.1.x-dev)
- In Drupal, add a menu item to the main menu (e.g., at /admin/structure/menu/manage/main/add).
- Use this external URL for that link: "https://www.drupal.org"
- Save it
- Go to /admin/reports/dblog.
- Notice that you see an error message of type "patternkit", with the error metioned above.

Proposed resolution

See proposed MR.

Remaining tasks

Review and testing
Release

Issue fork patternkit-3541404

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

krisahil created an issue. See original summary.

slucero made their first commit to this issue’s fork.

slucero’s picture

Status: Active » Needs review

Good catch @krisahil! Thank you for reporting this and posting the fix. I've made a couple of small tweaks for making sure array values exist and added unit tests for the class. With that, this should be ready for review and testing.

slucero’s picture

Issue summary: View changes
krisahil’s picture

Status: Needs review » Reviewed & tested by the community

LGTM. Cannot reproduce original. bug report, after applying these changes.

  • slucero committed cd1f518a on 9.1.x authored by krisahil
    Issue #3541404: UnexpectedValueException for links without routes
    
slucero’s picture

Status: Reviewed & tested by the community » Fixed

Merged for inclusion in the 9.1.2 release.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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