{"action":"created","issue":{"url":"https://api.github.com/repos/Polymer/polymer-cli/issues/354","repository_url":"https://api.github.com/repos/Polymer/polymer-cli","labels_url":"https://api.github.com/repos/Polymer/polymer-cli/issues/354/labels{/name}","comments_url":"https://api.github.com/repos/Polymer/polymer-cli/issues/354/comments","events_url":"https://api.github.com/repos/Polymer/polymer-cli/issues/354/events","html_url":"https://github.com/Polymer/polymer-cli/issues/354","id":170228455,"number":354,"title":"Unhelpful error message for invalid polymer.json","user":{"login":"tony19","id":26580,"avatar_url":"https://avatars.githubusercontent.com/u/26580?v=3","gravatar_id":"","url":"https://api.github.com/users/tony19","html_url":"https://github.com/tony19","followers_url":"https://api.github.com/users/tony19/followers","following_url":"https://api.github.com/users/tony19/following{/other_user}","gists_url":"https://api.github.com/users/tony19/gists{/gist_id}","starred_url":"https://api.github.com/users/tony19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tony19/subscriptions","organizations_url":"https://api.github.com/users/tony19/orgs","repos_url":"https://api.github.com/users/tony19/repos","events_url":"https://api.github.com/users/tony19/events{/privacy}","received_events_url":"https://api.github.com/users/tony19/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-09T17:47:59Z","updated_at":"2016-08-23T21:50:08Z","closed_at":null,"body":"### Description\r\nWhen `polymer.json` contains invalid JSON (e.g., from a trailing comma on array element), `polymer-cli` emits a generic warning about `polymer.json` and continues to build, which leads to other build errors.\r\n\r\n```\r\n$ polymer build\r\nwarn:    Could not load config file \r\n{ path: 'polymer.json', err: {} }\r\n...\r\n```\r\n\r\nThis message is logged at [project-config.ts:40](https://github.com/Polymer/polymer-cli/blob/master/src/project-config.ts#L40), and this could be improved by storing the error message itself (instead of the error object) in the log metadata:\r\n```\r\n- logger.warn('Could not load config file', {path: filepath, err: error});\r\n+ logger.warn('Could not load config file', {path: filepath, err: error.message});\r\n```\r\n\r\nThis emits:\r\n\r\n```\r\n$ polymer build\r\nwarn:    Could not load config file \r\n{ path: 'polymer.json', err: 'Unexpected token ] in JSON at position 248' }\r\n...\r\n```\r\n\r\nFurther, the invalid JSON should fail the build immediately.\r\n\r\n### Versions & Environment\r\n- Polymer CLI: 0.14.0\r\n- node: 6.3.1\r\n- Operating System: OS X El Capitan\r\n\r\n#### Steps to Reproduce\r\n\r\n1. Create a project: `polymer init app-drawer-template`\r\n2. In `polymer.json`, add a trailing comma to an array element. Or copy the following into `polymer.json`:\r\n\r\n  ```json\r\n{\r\n  \"entrypoint\": \"index.html\",\r\n  \"shell\": \"src/my-app.html\",\r\n  \"fragments\": [\r\n    \"src/my-view1.html\",\r\n    \"src/my-view2.html\",\r\n    \"src/my-view3.html\",\r\n  ]\r\n}\r\n```\r\n3. Build: `polymer build`\r\n4. Observe the obscure warning (and subsequent build error).\r\n\r\n#### Expected Results\r\nFail-fast build error with specific error message\r\n\r\nExample:\r\n```\r\n$ polymer build\r\nerror:    Could not load config file \r\n{ path: 'polymer.json', err: 'Unexpected token ] in JSON at position 156' }\r\n```\r\n\r\n#### Actual Results\r\n```\r\n$ polymer build\r\nwarn:    Could not load config file \r\n{ path: 'polymer.json', err: {} }\r\n... continues to build, leading to red herrings ...\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Polymer/polymer-cli/issues/comments/241891276","html_url":"https://github.com/Polymer/polymer-cli/issues/354#issuecomment-241891276","issue_url":"https://api.github.com/repos/Polymer/polymer-cli/issues/354","id":241891276,"user":{"login":"FredKSchott","id":622227,"avatar_url":"https://avatars.githubusercontent.com/u/622227?v=3","gravatar_id":"","url":"https://api.github.com/users/FredKSchott","html_url":"https://github.com/FredKSchott","followers_url":"https://api.github.com/users/FredKSchott/followers","following_url":"https://api.github.com/users/FredKSchott/following{/other_user}","gists_url":"https://api.github.com/users/FredKSchott/gists{/gist_id}","starred_url":"https://api.github.com/users/FredKSchott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FredKSchott/subscriptions","organizations_url":"https://api.github.com/users/FredKSchott/orgs","repos_url":"https://api.github.com/users/FredKSchott/repos","events_url":"https://api.github.com/users/FredKSchott/events{/privacy}","received_events_url":"https://api.github.com/users/FredKSchott/received_events","type":"User","site_admin":false},"created_at":"2016-08-23T21:50:07Z","updated_at":"2016-08-23T21:50:07Z","body":"@tony19 thanks for the great issue description and for taking the time to think through this. I completely agree, we should exit if there's an error parsing the `polymer.json` file (but still continue if the file is just not found).\r\n\r\nWould anyone like to write the fix & a test for this?"}}
{"actor":{"display_login":"FredKSchott"}}