In #2773163: Unrouted URIs do not have internal representations, external URL routing was fixed inside the generateBundleUrls() method of BatchUrlGenerator, but not in the generateCustomUrls() method. I'll attach a patch which applies the same fix in that method (I was getting the same error, but it was in a custom URL it seems).

Full error from drush simple_sitemap-generate below:

Initializing batch...                                                                                           [status]
exception 'UnexpectedValueException' with message 'Unrouted URIs do not have internal representations.' in       [error]
/var/www/site/docroot/core/lib/Drupal/Core/Url.php:768
Stack trace:
#0 /var/www/site/docroot/modules/contrib/simple_sitemap/src/Batch/BatchUrlGenerator.php(178):
Drupal\Core\Url->getInternalPath()
#1 /var/www/site/docroot/modules/contrib/simple_sitemap/src/Batch/Batch.php(125):
Drupal\simple_sitemap\Batch\BatchUrlGenerator->generateCustomUrls(Array)
#2 [internal function]: Drupal\simple_sitemap\Batch\Batch::generateCustomUrls(Array, Array,
Object(DrushBatchContext))
#3 /var/www/site/vendor/drush/drush/commands/core/drupal/batch.inc(163):
call_user_func_array('Drupal\\simple_s...', Array)
#4 /var/www/site/vendor/drush/drush/commands/core/drupal/batch.inc(111): _drush_batch_worker()
#5 /var/www/site/vendor/drush/drush/includes/batch.inc(98): _drush_batch_command('23097')
#6 /var/www/site/vendor/drush/drush/commands/core/core.drush.inc(1206): drush_batch_command('23097')
#7 [internal function]: drush_core_batch_process('23097')
#8 /var/www/site/vendor/drush/drush/includes/command.inc(373): call_user_func_array('drush_core_batc...',
Array)
#9 /var/www/site/vendor/drush/drush/includes/command.inc(224): _drush_invoke_hooks(Array, Array)
#10 [internal function]: drush_command('23097')
#11 /var/www/site/vendor/drush/drush/includes/command.inc(192): call_user_func_array('drush_command', Array)
#12 /var/www/site/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#13 /var/www/site/vendor/drush/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#14 /var/www/site/vendor/drush/drush/drush.php(12): drush_main()
#15 {main}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geerlingguy created an issue. See original summary.

geerlingguy’s picture

Status: Active » Needs review
FileSize
587 bytes

Patch attached.

gbyte’s picture

The custom link form validator should prevent non-routed paths from being put in. Could you please investigate what kind of paths created this problem and how they made it into configuration?

Great work with the drupalvm BTW :)

gbyte’s picture

Status: Needs review » Active
geerlingguy’s picture

@gbyte.co - I'll try to figure out what was causing it at some point, but it could be a bit of time—I had to get that fixed for a client ASAP but won't be able to get back to that codebase/database for a while, most likely :/

They had about 12,000 URL paths in the sitemap, but I'm fairly certain it was a custom menu path for one of their menu links.

chrisfromredfin’s picture

I am having the same issue as @geerlingguy. Here's my stacktrace. My guess is that it's the full canonical link to the frontpage/homepage. This is on a dev instance, but having the same issue on production cron runs.

His patch "fixes" the issue (makes the error go away, anyway).

Command: drush8 -l http://gallerysystem.dev cron

Backtrace:

#0  Drupal\Core\Url->getInternalPath() called at [/Applications/MAMP/htdocs/d8-rfs/web/modules/contrib/simple_sitemap/src/Batch/BatchUrlGenerator.php:178]
#1  Drupal\simple_sitemap\Batch\BatchUrlGenerator->generateCustomUrls(Array ([0] => Array ([path] => /,[priority] => 1,[lastmod] => ),[1] => Array ([path] => /blog,[priority] => 0.6,[lastmod] => ),[2] => Array ([path] => /order-art-hanging-systems,[priority] => 0.4,[lastmod] => ),[3] => Array ([path] => /order-art-hanging-systems/original-gallery-system,[priority] => 0.4,[lastmod] => ),[4] => Array ([path] => /order-art-hanging-systems/galleryone,[priority] => 0.4,[lastmod] => ),[5] => Array ([path] => /order-art-hanging-systems/picture-molding-hangers-hooks,[priority] => 0.4,[lastmod] => ))) called at [/Applications/MAMP/htdocs/d8-rfs/web/modules/contrib/simple_sitemap/src/Batch/Batch.php:125]
#2  Drupal\simple_sitemap\Batch\Batch::generateCustomUrls(Array ([0] => Array ([path] => /,[priority] => 1,[lastmod] => ),[1] => Array ([path] => /blog,[priority] => 0.6,[lastmod] => ),[2] => Array ([path] => /order-art-hanging-systems,[priority] => 0.4,[lastmod] => ),[3] => Array ([path] => /order-art-hanging-systems/original-gallery-system,[priority] => 0.4,[lastmod] => ),[4] => Array ([path] => /order-art-hanging-systems/galleryone,[priority] => 0.4,[lastmod] => ),[5] => Array ([path] => /order-art-hanging-systems/picture-molding-hangers-hooks,[priority] => 0.4,[lastmod] => )), Array ([from] => backend,[batch_process_limit] => 1500,[max_links] => 2000,[skip_untranslated] => ,[remove_duplicates] => 1,[entity_types] => Array ([node] => Array ([blog_post] => Array ([index] => 1,[priority] => 0.5),[page] => Array ([index] => 1,[priority] => 0.5),[product_display] => Array ([index] => 1,[priority] => 0.5)))), Array ([sandbox] => Array ([progress] => 2,[current_id] => 1,[max] => 6),[results] => Array ([generate] => Array ([0] => Array ([path] => ,[lastmod] => ,[priority] => 1,[langcode] => en,[url] => http://gallerysystem.dev/,[alternate_urls] => Array ([en] => http://gallerysystem.dev/))),[processed_paths] => Array ([0] => )),[finished] => 1,[message] => ))
#3  call_user_func_array(Drupal\simple_sitemap\Batch\Batch::generateCustomUrls, Array ([0] => Array ([0] => Array ([path] => /,[priority] => 1,[lastmod] => ),[1] => Array ([path] => /blog,[priority] => 0.6,[lastmod] => ),[2] => Array ([path] => /order-art-hanging-systems,[priority] => 0.4,[lastmod] => ),[3] => Array ([path] => /order-art-hanging-systems/original-gallery-system,[priority] => 0.4,[lastmod] => ),[4] => Array ([path] => /order-art-hanging-systems/galleryone,[priority] => 0.4,[lastmod] => ),[5] => Array ([path] => /order-art-hanging-systems/picture-molding-hangers-hooks,[priority] => 0.4,[lastmod] => )),[1] => Array ([from] => backend,[batch_process_limit] => 1500,[max_links] => 2000,[skip_untranslated] => ,[remove_duplicates] => 1,[entity_types] => Array ([node] => Array ([blog_post] => Array ([index] => 1,[priority] => 0.5),[page] => Array ([index] => 1,[priority] => 0.5),[product_display] => Array ([index] => 1,[priority] => 0.5)))),[2] => Array ([sandbox] => Array ([progress] => 2,[current_id] => 1,[max] => 6),[results] => Array ([generate] => Array ([0] => Array ([path] => ,[lastmod] => ,[priority] => 1,[langcode] => en,[url] => http://gallerysystem.dev/,[alternate_urls] => Array ([en] => http://gallerysystem.dev/))),[processed_paths] => Array ([0] => )),[finished] => 1,[message] => ))) called at [/Applications/MAMP/htdocs/d8-rfs/web/core/includes/batch.inc:252]
#4  _batch_process() called at [/Applications/MAMP/htdocs/d8-rfs/web/core/includes/form.inc:870]
#5  batch_process() called at [/Applications/MAMP/htdocs/d8-rfs/web/modules/contrib/simple_sitemap/src/Batch/Batch.php:69]
#6  Drupal\simple_sitemap\Batch\Batch->start() called at [/Applications/MAMP/htdocs/d8-rfs/web/modules/contrib/simple_sitemap/src/SitemapGenerator.php:90]
#7  Drupal\simple_sitemap\SitemapGenerator->startGeneration() called at [/Applications/MAMP/htdocs/d8-rfs/web/modules/contrib/simple_sitemap/src/Simplesitemap.php:538]
#8  Drupal\simple_sitemap\Simplesitemap->generateSitemap(backend) called at [/Applications/MAMP/htdocs/d8-rfs/web/modules/contrib/simple_sitemap/simple_sitemap.module:111]
#9  simple_sitemap_cron()
#10 call_user_func_array(simple_sitemap_cron, Array ()) called at [/Applications/MAMP/htdocs/d8-rfs/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:391]
#11 Drupal\Core\Extension\ModuleHandler->invoke(simple_sitemap, cron) called at [/Applications/MAMP/htdocs/d8-rfs/web/core/lib/Drupal/Core/Cron.php:218]
#12 Drupal\Core\Cron->invokeCronHandlers() called at [/Applications/MAMP/htdocs/d8-rfs/web/core/lib/Drupal/Core/Cron.php:121]
#13 Drupal\Core\Cron->run() called at [/Applications/MAMP/htdocs/d8-rfs/web/core/lib/Drupal/Core/ProxyClass/Cron.php:75]
#14 Drupal\Core\ProxyClass\Cron->run() called at [/Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/commands/core/core.drush.inc:671]
#15 drush_core_cron()
#16 call_user_func_array(drush_core_cron, Array ()) called at [/Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/includes/command.inc:366]
#17 _drush_invoke_hooks(Array ([description] => Run all cron hooks in all active modules for specified site.,[aliases] => Array ([0] => cron),[topics] => Array ([0] => docs-cron),[command] => core-cron,[command-hook] => core-cron,[invoke hooks] => 1,[callback arguments] => Array (),[commandfile] => core,[path] => /Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/includes/../commands//core,[engines] => Array (),[callback] => drush_command,[primary function] => ,[sections] => Array ([examples] => Examples,[arguments] => Arguments,[options] => Options),[arguments] => Array (),[required-arguments] => ,[options] => Array (),[sub-options] => Array (),[allow-additional-options] => ,[global-options] => Array (),[examples] => Array (),[core] => Array (),[scope] => site,[drush dependencies] => Array (),[handle-remote-commands] => ,[remote-tty] => ,[strict-option-handling] => ,[tilde-expansion] => 1,[bootstrap_errors] => Array (),[hidden] => ,[category] => core,[drupal dependencies] => Array (),[bootstrap] => 6,[is_alias] => 1,[argument-description] => Array ()), Array ()) called at [/Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/includes/command.inc:217]
#18 drush_command()
#19 call_user_func_array(drush_command, Array ()) called at [/Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/includes/command.inc:185]
#20 drush_dispatch(Array ([description] => Run all cron hooks in all active modules for specified site.,[aliases] => Array ([0] => cron),[topics] => Array ([0] => docs-cron),[command] => core-cron,[command-hook] => core-cron,[invoke hooks] => 1,[callback arguments] => Array (),[commandfile] => core,[path] => /Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/includes/../commands//core,[engines] => Array (),[callback] => drush_command,[primary function] => ,[sections] => Array ([examples] => Examples,[arguments] => Arguments,[options] => Options),[arguments] => Array (),[required-arguments] => ,[options] => Array (),[sub-options] => Array (),[allow-additional-options] => ,[global-options] => Array (),[examples] => Array (),[core] => Array (),[scope] => site,[drush dependencies] => Array (),[handle-remote-commands] => ,[remote-tty] => ,[strict-option-handling] => ,[tilde-expansion] => 1,[bootstrap_errors] => Array (),[hidden] => ,[category] => core,[drupal dependencies] => Array (),[bootstrap] => 6,[is_alias] => 1,[argument-description] => Array ())) called at [/Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php:67]
#21 Drush\Boot\BaseBoot->bootstrap_and_dispatch() called at [/Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/includes/preflight.inc:66]
#22 drush_main() called at [/Applications/MAMP/htdocs/d8-rfs/vendor/drush/drush/drush.php:12]
UnexpectedValueException: Unrouted URIs do not have internal representations. in                             [error]
Drupal\Core\Url->getInternalPath() (line 769 of
/Applications/MAMP/htdocs/d8-rfs/web/core/lib/Drupal/Core/Url.php).
Cron run successful.                                                                                         [success]

I think the specific case is toward the bottom of #2 there - it's the only "external" URL I can see in the stacktrace:

 Array ([0] => Array ([path] => ,[lastmod] => ,[priority] => 1,[langcode] => en,[url] => http://gallerysystem.dev/,[alternate_urls] => Array ([en] => http://gallerysystem.dev/))),[processed_paths] => Array ([0] => )),[finished] => 1,[message] => ))
gbyte’s picture

@cwells How did this link get into the custom link configuration? Did you use the form or the API to import custom links?

chrisfromredfin’s picture

Looks like I did it.

added / as an entry through UI

gbyte’s picture

Title: Unrouted URIs do not have internal representations, part II » Custom links: Unrouted URIs do not have internal representations
Status: Active » Postponed (maintainer needs more info)

This can't be the home / path. I am guessing it is one of the other paths. I am not sure however how this error comes up, as there is form validation checking that the links put in are valid and during generation there is also a check which skips and logs all invalid custom links. If any of you guys could reproduce this error on a fresh instance, I will be happy to patch it.

geerlingguy’s picture

@gbyte.co - I did notice just now that updating a Features export changed the way the home page path is stored:

-  priority: '1.0'
+  priority: !!float 1

So now the exported simple_sitemap.custom.yml config file looks like:

-
  path: /
  priority: !!float 1
-
  path: /search

Maybe the way the config was exported previously (I think it was using Symfony's YAML component on this project) was making the import do something weird in the active config? I still can't reproduce the issue at this time.

chrisfromredfin’s picture

I can re-create this. I installed a bare Drupal 8 latest (8.2.4) and the latest stable simple_sitemap (8.x-2.8).

Create a view called "blog" that's a view of teasers of articles. Create a page display (be sure to set the path of the view to /blog). All other things are default settings on the view.

Add "/blog 0.6" to the custom links in the simple sitemap.

Invoke cron using drush (<- this is important, it does not happen when invoking cron through the UI).

chrisfromredfin’s picture

Status: Postponed (maintainer needs more info) » Active

Updating to active, I think the 'more info' was that it happens only when invoking cron using drush (drush version 8.1.8, btw).

gbyte’s picture

Status: Active » Postponed (maintainer needs more info)

I just tried to reproduce the issue by installing Drupal 8.2.5 and simple_sitemap 2.8 and tried regenerating through UI, cron and drush core-cron. No exceptions and no logged errors there. After deleting the view, the old link is logged as non-existant to watchdog during generation and there are no PHP exceptions. I am really surprised you got this on a new install but I need to be able to reproduce this myself to take action. Anyone else getting this on a fresh install?

pjcdawkins’s picture

I'm getting this.

Attempting to debug, it looks like via cron, any Url::fromUserInput('/foo') will be interpreted as unrouted.

Through the UI, there's no problem.

Tracing it further, the problem is in Url::fromInternalUri():

    $url = \Drupal::pathValidator()
      ->getUrlIfValidWithoutAccessCheck($uri_parts['path']) ?: static::fromUri('base:' . $uri_parts['path'], $options);

The condition fails (due to PathValidator::getPathAttributes() encountering a caught MethodNotAllowedException), so the $url is returned prefixed by base:, which means it's unrouted.

That MethodNotAllowedException appears because the method is interpreted as an empty string. But $_SERVER['REQUEST_METHOD'] is set to GET, even via Drush. The empty string is introduced somewhere and I don't understand where.

pjcdawkins’s picture

Category: Bug report » Support request
Status: Postponed (maintainer needs more info) » Active

A couple of hours later... I've found a solution.

This appears to relate to a Drush bug: https://github.com/drush-ops/drush/issues/2511

With the patch from here for Drush: https://github.com/drush-ops/drush/pull/2512.patch
it will work, and the sitemap produced is identical to the one produced via the UI.

That patch has been committed to Drush, but not yet released.

kentr’s picture

pjcdawkins alerted me to this issue.

The drush patch has been committed to 8.x and master, so you can get it by installing the dev versions.

Something like one of:

composer require drush/drush:8.x@dev
composer require drush/drush:master@dev

Because of the drush finder script, you have to do some workarounds to use these if you also have a project-specific drush (like if you're using Drupal Composer Template). The easiest way I got around it is by removing the project-specific drush completely.

pjcdawkins’s picture

kentr: if you're using a project-specific drush with Composer, you can add a project-specific patch in composer.json:

    "require": {
        // etc.
        "cweagans/composer-patches": "~1.0"
    },
    "extra": {
        "patches": {
            "drush/drush": {
                "Fix REQUEST_METHOD bug": "https://patch-diff.githubusercontent.com/raw/drush-ops/drush/pull/2512.patch"
            }
        }
    },
kentr’s picture

Ah, nice trick.

chrisfromredfin’s picture

Project: Simple XML sitemap » Drush
Version: 8.x-2.x-dev » 8.x-6.x-dev
Component: Code » Base system (internal API)

I had some dependency issues trying to update my local drush to 8.2.x-dev, so I manually applied the patch and can confirm this fixes the issue. Drush issue, not Simple Sitemap's.

I know drush issues are handled in their github, but wanted to make sure the issue queue reflects the right project.

chrisfromredfin’s picture

Status: Active » Fixed
gbyte’s picture

Good work guys, thanks for the investigation and quick commits.

Status: Fixed » Closed (fixed)

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