{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/22880","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/22880/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/22880/comments","events_url":"https://api.github.com/repos/docker/docker/issues/22880/events","html_url":"https://github.com/docker/docker/pull/22880","id":156099639,"number":22880,"title":"Return remote API errors as JSON","user":{"login":"bfirsh","id":40906,"avatar_url":"https://avatars.githubusercontent.com/u/40906?v=3","gravatar_id":"","url":"https://api.github.com/users/bfirsh","html_url":"https://github.com/bfirsh","followers_url":"https://api.github.com/users/bfirsh/followers","following_url":"https://api.github.com/users/bfirsh/following{/other_user}","gists_url":"https://api.github.com/users/bfirsh/gists{/gist_id}","starred_url":"https://api.github.com/users/bfirsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfirsh/subscriptions","organizations_url":"https://api.github.com/users/bfirsh/orgs","repos_url":"https://api.github.com/users/bfirsh/repos","events_url":"https://api.github.com/users/bfirsh/events{/privacy}","received_events_url":"https://api.github.com/users/bfirsh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/impact/api","name":"impact/api","color":"bfe5bf"},{"url":"https://api.github.com/repos/docker/docker/labels/impact/changelog","name":"impact/changelog","color":"bfe5bf"},{"url":"https://api.github.com/repos/docker/docker/labels/status/1-design-review","name":"status/1-design-review","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2016-05-21T12:26:33Z","updated_at":"2016-05-25T18:38:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/22880","html_url":"https://github.com/docker/docker/pull/22880","diff_url":"https://github.com/docker/docker/pull/22880.diff","patch_url":"https://github.com/docker/docker/pull/22880.patch"},"body":"<!--\r\nPlease make sure you've read and understood our contributing guidelines;\r\nhttps://github.com/docker/docker/blob/master/CONTRIBUTING.md\r\n\r\n** Make sure all your commits include a signature generated with `git commit -s` **\r\n\r\nFor additional information on our contributing process, read our contributing\r\nguide https://docs.docker.com/opensource/code/\r\n\r\nIf this is a bug fix, make sure your description includes \"fixes #xxxx\", or\r\n\"closes #xxxx\"\r\n\r\nPlease provide the following information:\r\n-->\r\n\r\n**- What I did**\r\n\r\nThe Remote API returns JSON responses on success and plain text responses on failure. [There have been complaints that this is unexpected.](https://github.com/docker/engine-api/issues/77#issuecomment-216466034) [It is also impossible to represent this using a Swagger API definition.](https://github.com/docker/engine-api/issues/77#issuecomment-216415405) It has also been mentioned in #5893.\r\n\r\nThis pull request makes the response body of API errors JSON in the form `{\"code\": ..., \"message\": ...}`. API versions <1.24 will continue to return plain text errors.\r\n\r\nIt depends upon https://github.com/docker/engine-api/pull/233 but this PR is ready to review besides vendoring that.\r\n\r\n**- How I did it**\r\n\r\nIt uses `jsonmessage.JSONError` to represent errors which seemed appropriate. This is conflating it somewhat with the streaming JSON responses, so if it's felt that this should be a separate object, happy to do that.\r\n\r\n**- How to verify it**\r\n\r\n```\r\n$ curl localhost:2375/fdshjkfdsfd\r\n{\"code\":404,\"message\":\"page not found\"}\r\n$ curl localhost:2375/v1.24/fdshjkfdsfd\r\n{\"code\":404,\"message\":\"page not found\"}\r\n$ curl localhost:2375/v1.23/fdshjkfdsfd\r\npage not found\r\n$ curl -X POST --data \"{}\" -H \"Content-Type: application/json\" localhost:2375/containers/create\r\n{\"code\":500,\"message\":\"Config cannot be empty in order to create a container\"}\r\n$ curl -X POST --data \"{}\" -H \"Content-Type: application/json\" localhost:2375/v1.23/containers/create\r\nConfig cannot be empty in order to create a container\r\n```\r\n\r\n**- Description for the changelog**\r\n<!--\r\nWrite a short (one line) summary that describes the changes in this\r\npull request for inclusion in the changelog:\r\n-->\r\nRemote API errors are now returned as JSON.\r\n\r\n**- A picture of a cute animal (not mandatory but encouraged)**\r\n\r\n![404](https://cloud.githubusercontent.com/assets/40906/15448332/fc45fede-1f56-11e6-8af4-119f04f209a5.jpg)\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/221666991","html_url":"https://github.com/docker/docker/pull/22880#issuecomment-221666991","issue_url":"https://api.github.com/repos/docker/docker/issues/22880","id":221666991,"user":{"login":"bfirsh","id":40906,"avatar_url":"https://avatars.githubusercontent.com/u/40906?v=3","gravatar_id":"","url":"https://api.github.com/users/bfirsh","html_url":"https://github.com/bfirsh","followers_url":"https://api.github.com/users/bfirsh/followers","following_url":"https://api.github.com/users/bfirsh/following{/other_user}","gists_url":"https://api.github.com/users/bfirsh/gists{/gist_id}","starred_url":"https://api.github.com/users/bfirsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfirsh/subscriptions","organizations_url":"https://api.github.com/users/bfirsh/orgs","repos_url":"https://api.github.com/users/bfirsh/repos","events_url":"https://api.github.com/users/bfirsh/events{/privacy}","received_events_url":"https://api.github.com/users/bfirsh/received_events","type":"User","site_admin":false},"created_at":"2016-05-25T18:38:04Z","updated_at":"2016-05-25T18:38:04Z","body":"@cpuguy83 Pretty much what @justincormack said. It's also makes it harder to write clients, and it is impossible to specify with a Swagger API specification.\r\n\r\nI have updated this PR to use `ErrorResponse` from engine-api to represent errors instead of the `jsonmessage.APIError`. This also removes the `code` key to make this as uncontroversial as possible. It has dubious value, and `message` is the only thing that's essential to make this change. If we decide upon a standard way to represent errors, we can start adding more fields."}}
{"actor":{"display_login":"bfirsh"}}