{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/4234","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/4234/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/4234/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/4234/events","html_url":"https://github.com/magento/magento2/issues/4234","id":149539773,"number":4234,"title":"404 when trying to display product view page (product.info.main container label is missing)","user":{"login":"leoquijano","id":7789514,"avatar_url":"https://avatars.githubusercontent.com/u/7789514?v=3","gravatar_id":"","url":"https://api.github.com/users/leoquijano","html_url":"https://github.com/leoquijano","followers_url":"https://api.github.com/users/leoquijano/followers","following_url":"https://api.github.com/users/leoquijano/following{/other_user}","gists_url":"https://api.github.com/users/leoquijano/gists{/gist_id}","starred_url":"https://api.github.com/users/leoquijano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leoquijano/subscriptions","organizations_url":"https://api.github.com/users/leoquijano/orgs","repos_url":"https://api.github.com/users/leoquijano/repos","events_url":"https://api.github.com/users/leoquijano/events{/privacy}","received_events_url":"https://api.github.com/users/leoquijano/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-19T18:12:20Z","updated_at":"2016-04-19T20:53:10Z","closed_at":null,"body":"Hi,\r\n\r\nI'm developing a custom theme and I was stuck with a 404 error when displaying the product view page: \r\n\r\nhttp://mystore.dev/some-product\r\n\r\nI first thought that this was a problem with my own setup, but then I went in to debug some exceptions I was getting. Particularly this one:\r\n\r\n```\r\n[2016-04-19 17:46:50] main.CRITICAL: Exception: Notice: Undefined index: label in /var/www/html/my-store/vendor/magento/framework/View/Layout/Generator/Container.php on line 90 in /var/www/html/my-store/vendor/magento/framework/App/ErrorHandler.php:61\r\nStack trace:\r\n#0 /var/www/html/my-store/vendor/magento/framework/View/Layout/Generator/Container.php(90): Magento\\Framework\\App\\ErrorHandler->handler(8, 'Undefined index...', '/var/www/html/o...', 90, Array)\r\n#1 /var/www/html/my-store/vendor/magento/framework/View/Layout/Generator/Container.php(67): Magento\\Framework\\View\\Layout\\Generator\\Container->generateContainer(Object(Magento\\Framework\\View\\Layout\\Data\\Structure), 'product.info.ma...', Array)\r\n#2 /var/www/html/my-store/vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\\Framework\\View\\Layout\\Generator\\Container->process(Object(Magento\\Framework\\View\\Layout\\Reader\\Context), Object(Magento\\Framework\\View\\Layout\\Generator\\Context))\r\n#3 /var/www/html/my-store/vendor/magento/framework/View/Layout.php(327): Magento\\Framework\\View\\Layout\\GeneratorPool->process(Object(Magento\\Framework\\View\\Layout\\Reader\\Context), Object(Magento\\Framework\\View\\Layout\\Generator\\Context))\r\n#4 /var/www/html/my-store/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\\Framework\\View\\Layout->generateElements()\r\n#5 /var/www/html/my-store/vendor/magento/framework/View/Layout/Builder.php(129): Magento\\Framework\\View\\Layout\\Interceptor->generateElements()\r\n#6 /var/www/html/my-store/vendor/magento/framework/View/Page/Builder.php(55): Magento\\Framework\\View\\Layout\\Builder->generateLayoutBlocks()\r\n#7 /var/www/html/my-store/vendor/magento/framework/View/Layout/Builder.php(65): Magento\\Framework\\View\\Page\\Builder->generateLayoutBlocks()\r\n#8 /var/www/html/my-store/vendor/magento/framework/View/Page/Config.php(166): Magento\\Framework\\View\\Layout\\Builder->build()\r\n#9 /var/www/html/my-store/vendor/magento/framework/View/Page/Config.php(475): Magento\\Framework\\View\\Page\\Config->build()\r\n#10 /var/www/html/my-store/vendor/magento/framework/View/Page/Config.php(433): Magento\\Framework\\View\\Page\\Config->getElementAttribute('body', 'class')\r\n#11 /var/www/html/my-store/vendor/magento/module-catalog/Helper/Product/View.php(159): Magento\\Framework\\View\\Page\\Config->addBodyClass('catalog-product...')\r\n#12 /var/www/html/my-store/vendor/magento/module-catalog/Helper/Product/View.php(214): Magento\\Catalog\\Helper\\Product\\View->initProductLayout(Object(Magento\\Framework\\View\\Result\\Page\\Interceptor), Object(Magento\\Catalog\\Model\\Product\\Interceptor), Object(Magento\\Framework\\DataObject))\r\n#13 /var/www/html/my-store/vendor/magento/module-catalog/Controller/Product/View.php(109): Magento\\Catalog\\Helper\\Product\\View->prepareAndRender(Object(Magento\\Framework\\View\\Result\\Page\\Interceptor), 233, Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Object(Magento\\Framework\\DataObject))\r\n#14 /var/www/html/my-store/var/generation/Magento/Catalog/Controller/Product/View/Interceptor.php(24): Magento\\Catalog\\Controller\\Product\\View->execute()\r\n#15 /var/www/html/my-store/vendor/magento/framework/App/Action/Action.php(102): Magento\\Catalog\\Controller\\Product\\View\\Interceptor->execute()\r\n#16 [internal function]: Magento\\Framework\\App\\Action\\Action->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\r\n#17 /var/www/html/my-store/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)\r\n#18 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\\Catalog\\Controller\\Product\\View\\Interceptor->___callParent('dispatch', Array)\r\n#19 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Catalog...', 'dispatch', Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Array, 'designLoader')\r\n#20 /var/www/html/my-store/vendor/magento/framework/App/Action/Plugin/Design.php(39): Magento\\Framework\\Interception\\Chain\\Chain->Magento\\Framework\\Interception\\Chain\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#21 [internal function]: Magento\\Framework\\App\\Action\\Plugin\\Design->aroundDispatch(Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#22 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)\r\n#23 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Catalog...', 'dispatch', Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Array, 'contextPlugin')\r\n#24 /var/www/html/my-store/vendor/magento/module-store/App/Action/Plugin/Context.php(98): Magento\\Framework\\Interception\\Chain\\Chain->Magento\\Framework\\Interception\\Chain\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#25 [internal function]: Magento\\Store\\App\\Action\\Plugin\\Context->aroundDispatch(Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#26 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)\r\n#27 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Catalog...', 'dispatch', Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Array, 'customer-app-ac...')\r\n#28 /var/www/html/my-store/vendor/magento/module-customer/Model/App/Action/ContextPlugin.php(61): Magento\\Framework\\Interception\\Chain\\Chain->Magento\\Framework\\Interception\\Chain\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#29 [internal function]: Magento\\Customer\\Model\\App\\Action\\ContextPlugin->aroundDispatch(Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#30 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)\r\n#31 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Catalog...', 'dispatch', Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Array, 'storeCheck')\r\n#32 /var/www/html/my-store/vendor/magento/module-store/App/Action/Plugin/StoreCheck.php(44): Magento\\Framework\\Interception\\Chain\\Chain->Magento\\Framework\\Interception\\Chain\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#33 [internal function]: Magento\\Store\\App\\Action\\Plugin\\StoreCheck->aroundDispatch(Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#34 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)\r\n#35 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Catalog...', 'dispatch', Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Array, 'weee-app-action...')\r\n#36 /var/www/html/my-store/vendor/magento/module-weee/Model/App/Action/ContextPlugin.php(112): Magento\\Framework\\Interception\\Chain\\Chain->Magento\\Framework\\Interception\\Chain\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#37 [internal function]: Magento\\Weee\\Model\\App\\Action\\ContextPlugin->aroundDispatch(Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#38 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)\r\n#39 /var/www/html/my-store/vendor/magento/framework/Interception/Interceptor.php(136): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Catalog...', 'dispatch', Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Array, 'tax-app-action-...')\r\n#40 /var/www/html/my-store/vendor/magento/module-tax/Model/App/Action/ContextPlugin.php(91): Magento\\Catalog\\Controller\\Product\\View\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#41 [internal function]: Magento\\Tax\\Model\\App\\Action\\ContextPlugin->aroundDispatch(Object(Magento\\Catalog\\Controller\\Product\\View\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#42 /var/www/html/my-store/vendor/magento/framework/Interception/Interceptor.php(140): call_user_func_array(Array, Array)\r\n#43 /var/www/html/my-store/var/generation/Magento/Catalog/Controller/Product/View/Interceptor.php(39): Magento\\Catalog\\Controller\\Product\\View\\Interceptor->___callPlugins('dispatch', Array, Array)\r\n#44 /var/www/html/my-store/vendor/magento/framework/App/FrontController.php(55): Magento\\Catalog\\Controller\\Product\\View\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\r\n#45 [internal function]: Magento\\Framework\\App\\FrontController->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\r\n#46 /var/www/html/my-store/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)\r\n#47 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\\Framework\\App\\FrontController\\Interceptor->___callParent('dispatch', Array)\r\n#48 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Framewo...', 'dispatch', Object(Magento\\Framework\\App\\FrontController\\Interceptor), Array, 'requestPreproce...')\r\n#49 /var/www/html/my-store/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(89): Magento\\Framework\\Interception\\Chain\\Chain->Magento\\Framework\\Interception\\Chain\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#50 [internal function]: Magento\\Store\\App\\FrontController\\Plugin\\RequestPreprocessor->aroundDispatch(Object(Magento\\Framework\\App\\FrontController\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#51 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)\r\n#52 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Framewo...', 'dispatch', Object(Magento\\Framework\\App\\FrontController\\Interceptor), Array, 'install')\r\n#53 /var/www/html/my-store/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\\Framework\\Interception\\Chain\\Chain->Magento\\Framework\\Interception\\Chain\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#54 [internal function]: Magento\\Framework\\Module\\Plugin\\DbStatusValidator->aroundDispatch(Object(Magento\\Framework\\App\\FrontController\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#55 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)\r\n#56 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Framewo...', 'dispatch', Object(Magento\\Framework\\App\\FrontController\\Interceptor), Array, 'front-controlle...')\r\n#57 /var/www/html/my-store/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\\Framework\\Interception\\Chain\\Chain->Magento\\Framework\\Interception\\Chain\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#58 [internal function]: Magento\\PageCache\\Model\\App\\FrontController\\VarnishPlugin->aroundDispatch(Object(Magento\\Framework\\App\\FrontController\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#59 /var/www/html/my-store/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)\r\n#60 /var/www/html/my-store/vendor/magento/framework/Interception/Interceptor.php(136): Magento\\Framework\\Interception\\Chain\\Chain->invokeNext('Magento\\\\Framewo...', 'dispatch', Object(Magento\\Framework\\App\\FrontController\\Interceptor), Array, 'front-controlle...')\r\n#61 /var/www/html/my-store/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(68): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\r\n#62 [internal function]: Magento\\PageCache\\Model\\App\\FrontController\\BuiltinPlugin->aroundDispatch(Object(Magento\\Framework\\App\\FrontController\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\r\n#63 /var/www/html/my-store/vendor/magento/framework/Interception/Interceptor.php(140): call_user_func_array(Array, Array)\r\n#64 /var/www/html/my-store/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\\Framework\\App\\FrontController\\Interceptor->___callPlugins('dispatch', Array, Array)\r\n#65 /var/www/html/my-store/vendor/magento/framework/App/Http.php(115): Magento\\Framework\\App\\FrontController\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\r\n#66 /var/www/html/my-store/vendor/magento/framework/App/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\r\n#67 /var/www/html/my-store/pub/index.php(37): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\r\n#68 {main} [] []\r\n```\r\nSince I'm developing my theme on top of the ```theme-frontend-blank``` theme, I suspected that there was an issue with the most basic theme setup, an issue that might not be visible if I were using a theme that overrides some of the containers. \r\n\r\nSo I went to debug ```/vendor/magento/framework/View/Layout/Generator/Container.php``` line 90 (as described in the extension), and found this:\r\n\r\n```php\r\npublic function generateContainer(\r\n    Layout\\Data\\Structure $structure,\r\n    $elementName,\r\n    $options\r\n) {\r\n    $structure->setAttribute(\r\n        $elementName,\r\n        Layout\\Element::CONTAINER_OPT_LABEL,\r\n        $options[Layout\\Element::CONTAINER_OPT_LABEL]\r\n    );\r\n    unset($options[Layout\\Element::CONTAINER_OPT_LABEL]);\r\n    unset($options['type']);\r\n     $this->validateOptions($options);\r\n     foreach ($options as $key => $value) {\r\n        $structure->setAttribute($elementName, $key, $value);\r\n    }\r\n}\r\n```\r\n\r\nThere you can see how some attributes are set to a container. The ```CONTAINER_OPT_LABEL``` attribute (i.e. \"label\") gets a special treatment. It is directly retrieved from the ```$options``` array, and then set. The other attributes are set later.\r\n\r\nI then found out that even though most containers have labels, this one doesn't:\r\n\r\n/vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml (line 30):\r\n```\r\n<container name=\"product.info.main\" htmlTag=\"div\" htmlClass=\"product-info-main\" before=\"-\">\r\n```\r\n\r\nNow: not all PHP configurations are so strict as to throw an exception due to an invalid index error. Mine is. I'm using PHP 7.0.5-2 on top of an Ubuntu setup (Homestead). It's clear that there's an issue with this layout file. I'm not sure if all containers **should** have labels and this just doesn't, or if the container process **should** handle missing labels well.\r\n\r\nAs a workaround, I changed ```Container.php``` like this, and that fixed the problem for me. This, of course, will only work until the next update comes around, so I hope an official fix can be made?\r\n\r\n```php\r\npublic function generateContainer(\r\n    Layout\\Data\\Structure $structure,\r\n    $elementName,\r\n    $options\r\n) {\r\n    if(isset($options[Layout\\Element::CONTAINER_OPT_LABEL])) {\r\n      $structure->setAttribute(\r\n          $elementName,\r\n          Layout\\Element::CONTAINER_OPT_LABEL,\r\n          $options[Layout\\Element::CONTAINER_OPT_LABEL]\r\n      );\r\n      unset($options[Layout\\Element::CONTAINER_OPT_LABEL]);\r\n    }\r\n    unset($options['type']);\r\n     $this->validateOptions($options);\r\n     foreach ($options as $key => $value) {\r\n        $structure->setAttribute($elementName, $key, $value);\r\n    }\r\n}\r\n```\r\n\r\nWhy didn't I just override the container and added the label? I wanted to avoid any other issues like this with other containers. But that workaround is also good.\r\n\r\nI'm using Magento 2.0.4, but I took a look at the HEAD source code and the issue seems to be still there at the moment I write this:\r\n\r\nhttps://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/View/Layout/Generator/Container.php\r\nhttps://github.com/magento/magento2/blob/develop/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml\r\n\r\nLastly, I would like to point out that the 404 error caused by this error is a bit misleading and might cause confusion with some developers. Perhaps there's a better way to display these errors to developers?\r\n\r\nThanks in advance for your attention."},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/212122577","html_url":"https://github.com/magento/magento2/issues/4234#issuecomment-212122577","issue_url":"https://api.github.com/repos/magento/magento2/issues/4234","id":212122577,"user":{"login":"leoquijano","id":7789514,"avatar_url":"https://avatars.githubusercontent.com/u/7789514?v=3","gravatar_id":"","url":"https://api.github.com/users/leoquijano","html_url":"https://github.com/leoquijano","followers_url":"https://api.github.com/users/leoquijano/followers","following_url":"https://api.github.com/users/leoquijano/following{/other_user}","gists_url":"https://api.github.com/users/leoquijano/gists{/gist_id}","starred_url":"https://api.github.com/users/leoquijano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leoquijano/subscriptions","organizations_url":"https://api.github.com/users/leoquijano/orgs","repos_url":"https://api.github.com/users/leoquijano/repos","events_url":"https://api.github.com/users/leoquijano/events{/privacy}","received_events_url":"https://api.github.com/users/leoquijano/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T20:53:10Z","updated_at":"2016-04-19T20:53:10Z","body":"An additional item of information here. I just noticed that for some reason I had a ```referenceBlock``` in my ```Magento_Theme/default.xml file:\r\n\r\n```\r\n<referenceBlock name=\"product.info.main\">\r\n  <arguments>\r\n    <argument name=\"htmlClass\" xsi:type=\"string\">product-info-main fixed-sidebar</argument>\r\n  </arguments>\r\n</referenceBlock>\r\n```\r\n(I was adding a CSS class to the block)\r\n\r\nWhen I remove it (or move it to ```catalog_product_view.xml```), the 404 error goes away, even without my core code changes. So this makes this issue less critical. But it may be a good idea to check anyway."}}