When using tokens in a path alias similar to [node:menu-link:parent:url:path] and the parent menu link is an external URL, Url::getInternalPath() throws "Drupal\Core\Entity\EntityStorageException: Unrouted URIs do not have internal representations."

Steps to reproduce:

  1. Create a menu link that is an external (i.e, unrouted) URL.
  2. Create a pathauto pattern similar to the above and assign to a content type.
  3. Create content of the type chosen above and assign it as a child of the unrouted menu item.
  4. Save the node and the exception is thrown.

I will attach a patch that appears to address the issue, although I have not tested it thoroughly. Also, this patch silently fails to tokenize the path (instead it is left as '/'), as I am not certain what the desired behavior is in this case. Worth discussing I think.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

acy76 created an issue. See original summary.

acy76’s picture

Patch attached, please review.

SpadXIII’s picture

Status: Active » Needs review

This patch seems to have solved an issue for me as well. I have a url pattern set up as "[node:menu-link:parent:url:path]/[node:title]" and saving a node (using a hook_update_N) that follows this pattern threw an error in the console.

  • Failed: Unrouted URIs do not have internal representations.

Not marking it RBTC, as I'm still unsure about further implications. As far as I could see, there aren't any in my project.

miro_dietiker’s picture

Priority: Normal » Major

This is imho pretty easy to trigger in common scenarios and the application dies. Thus seems like a major issue to me?

  • Berdir committed 78aedb0 on 8.x-1.x authored by acy76
    Issue #2828603 by acy76: URL token throws exception when URL is unrouted
    
Berdir’s picture

Title: URL token throws exception when URL is unrouted » Needs tests: URL token throws exception when URL is unrouted
Category: Bug report » Task
Priority: Major » Normal
Status: Needs review » Active

Yeah, decided to commit this, but would be nice to have test coverage, so keeping open for that.

miro_dietiker’s picture

Issue tags: +Needs tests