Search code examples
urlurl-routingdrupal-8

Drupal 8 issue: InvalidArgumentException: The URI '' is invalid


I am struggling with this issue:

InvalidArgumentException: The URI '' is invalid.
You must use a valid URI scheme. in Drupal\Core\Url::fromUri() 
(line 284 of core/lib/Drupal/Core/Url.php).

How can I fix this?


Solution

  • You are passing a blank uri into the method. It is complaining about missing a scheme (eg. http:// or https://, or an internal scheme eg: internal:/)

    So either you are explicitly passing a blank, or something isn't being set correctly. However, it does not seem to be null.