user3292506
user3292506

Reputation: 25

Zend framework error in magento 2

I am developing ecommerce website in magento 2. I got error when I am adding products from home page:

Zend\Uri\Exception\InvalidUriException: URI is not valid and cannot be converted into a string in /var/www/html/voylite/vendor/zendframework/zend-uri/src/Uri.php:359 Stack trace: #0
/var/www/html/voylite/vendor/zendframework/zend-http/src/Header/AbstractLocation.php(98): Zend\Uri\Uri->toString() #1
/var/www/html/voylite/vendor/zendframework/zend-http/src/Header/AbstractLocation.php(133): Zend\Http\Header\AbstractLocation->getUri() #2
/var/www/html/voylite/vendor/zendframework/zend-http/src/PhpEnvironment/Response.php(98): Zend\Http\Header\AbstractLocation->toString() #3
/var/www/html/voylite/var/generation/Magento/Framework/App/Response/Http/Interceptor.php(310): Zend\Http\PhpEnvironment\Response->sendHeaders() #4
/var/www/html/voylite/vendor/zendframework/zend-http/src/PhpEnvironment/Response.php(128): Magento\Framework\App\Response\Http\Interceptor->sendHeaders() #5
/var/www/html/voylite/var/generation/Magento/Framework/App/Response/Http/Interceptor.php(336): Zend\Http\PhpEnvironment\Response->send() #6
/var/www/html/voylite/vendor/magento/framework/HTTP/PhpEnvironment/Response.php(44): Magento\Framework\App\Response\Http\Interceptor->send() #7
/var/www/html/voylite/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Framework\HTTP\PhpEnvironment\Response->sendResponse() #8
/var/www/html/voylite/var/generation/Magento/Framework/App/Response/Http/Interceptor.php(117): Magento\Framework\App\Response\Http\Interceptor->___callPlugins('sendResponse', Array, Array) #9
/var/www/html/voylite/vendor/magento/framework/App/Http.php(185): Magento\Framework\App\Response\Http\Interceptor->sendResponse() #10
/var/www/html/voylite/vendor/magento/framework/App/Http.php(156): Magento\Framework\App\Http->handleDeveloperMode(Object(Magento\Framework\App\Bootstrap), Object(Zend\Uri\Exception\InvalidUriException)) #11
/var/www/html/voylite/vendor/magento/framework/App/Bootstrap.php(263): Magento\Framework\App\Http->catchException(Object(Magento\Framework\App\Bootstrap), Object(Zend\Uri\Exception\InvalidUriException)) #12
/var/www/html/voylite/index.php(38): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http)) #13 {main}

Upvotes: 1

Views: 3214

Answers (3)

Amit Garg
Amit Garg

Reputation: 3907

It happens if URL to which redirection is being sent is invalid or blank. There is problem with this error stack because we can not find the actual line of code from where it is happened because error is starting after toURL method. Which is the part of ZF2 core.

Upvotes: 0

Anthony BONNIER
Anthony BONNIER

Reputation: 355

For further help, I've got the exact same error while developping an Ajax Controller/Action.

I was preparing the $result object to send the response :

$result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

And in some cases, set the redirection URL, depending of the treatement result :

$result->setUrl($this->_url->getUrl('checkout/onepage/success'));

But in one specific case, I've forgotten to set the URL and it caused the previous error. I've struggle a bit before finding out that the problem came from this little mistake.

I hope this may help someone else.

Upvotes: 1

delboy1978uk
delboy1978uk

Reputation: 12355

The URI which you have set is invalid, fix it. Difficult to offer more help without actually seeing what your input is.

Upvotes: 1

Related Questions