{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/13787","labels_url":"https://api.github.com/repos/docker/docker/issues/13787/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/13787/comments","events_url":"https://api.github.com/repos/docker/docker/issues/13787/events","html_url":"https://github.com/docker/docker/pull/13787","id":85780050,"number":13787,"title":"Avoid nil pointer dereference while creating a container with an empty Config","user":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/kind/bug","name":"kind/bug","color":"FF8C94"},{"url":"https://api.github.com/repos/docker/docker/labels/status/2-needs-code-review","name":"status/2-needs-code-review","color":"fad8c7"}],"state":"closed","locked":false,"assignee":{"login":"jfrazelle","id":1445228,"avatar_url":"https://avatars.githubusercontent.com/u/1445228?v=3","gravatar_id":"","url":"https://api.github.com/users/jfrazelle","html_url":"https://github.com/jfrazelle","followers_url":"https://api.github.com/users/jfrazelle/followers","following_url":"https://api.github.com/users/jfrazelle/following{/other_user}","gists_url":"https://api.github.com/users/jfrazelle/gists{/gist_id}","starred_url":"https://api.github.com/users/jfrazelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfrazelle/subscriptions","organizations_url":"https://api.github.com/users/jfrazelle/orgs","repos_url":"https://api.github.com/users/jfrazelle/repos","events_url":"https://api.github.com/users/jfrazelle/events{/privacy}","received_events_url":"https://api.github.com/users/jfrazelle/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/docker/docker/milestones/38","html_url":"https://github.com/docker/docker/milestones/1.7.0","labels_url":"https://api.github.com/repos/docker/docker/milestones/38/labels","id":1010239,"number":38,"title":"1.7.0","description":"Freeze May 26\r\nRelease  June 16","creator":{"login":"dmcgowan","id":169601,"avatar_url":"https://avatars.githubusercontent.com/u/169601?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcgowan","html_url":"https://github.com/dmcgowan","followers_url":"https://api.github.com/users/dmcgowan/followers","following_url":"https://api.github.com/users/dmcgowan/following{/other_user}","gists_url":"https://api.github.com/users/dmcgowan/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcgowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcgowan/subscriptions","organizations_url":"https://api.github.com/users/dmcgowan/orgs","repos_url":"https://api.github.com/users/dmcgowan/repos","events_url":"https://api.github.com/users/dmcgowan/events{/privacy}","received_events_url":"https://api.github.com/users/dmcgowan/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":95,"state":"open","created_at":"2015-03-07T01:54:49Z","updated_at":"2015-06-08T16:36:36Z","due_on":"2016-05-16T07:00:00Z","closed_at":null},"comments":3,"created_at":"2015-06-06T16:44:40Z","updated_at":"2015-06-08T18:38:25Z","closed_at":"2015-06-07T16:28:41Z","pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/13787","html_url":"https://github.com/docker/docker/pull/13787","diff_url":"https://github.com/docker/docker/pull/13787.diff","patch_url":"https://github.com/docker/docker/pull/13787.patch"},"body":"Trying to create a container with an empty json object results in a nil pointer dereference panic. \r\nI found this on latest master (I haven't checked against other versions)\r\n\r\nStep to reproduce:\r\n```\r\nroot@1dadd042fabe:/go/src/github.com/docker/docker# curl -H \"Content-Type: application/json\" -X POST -d \"{}\" http://localhost:2375/containers/create\r\ncurl: (52) Empty reply from server\r\nroot@1dadd042fabe:/go/src/github.com/docker/docker#\r\n```\r\nand the resulted server side panic:\r\n```\r\n2015/06/06 16:28:04 http: panic serving [::1]:39607: runtime error: invalid memory address or nil pointer dereference\r\ngoroutine 46 [running]:\r\nnet/http.func·011()\r\n\t/usr/local/go/src/net/http/server.go:1130 +0xbb\r\ngithub.com/docker/docker/daemon.(*Daemon).ContainerCreate(0xc2080b4380, 0x0, 0x0, 0x0, 0xc20841ed80, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\r\n\t/go/src/github.com/docker/docker/daemon/create.go:26 +0x128\r\ngithub.com/docker/docker/api/server.(*Server).postContainersCreate(0xc2080c04c0, 0xdb8000, 0x4, 0x7f73d88a2320, 0xc208174be0, 0xc2080f5790, 0xc208409020, 0x0, 0x0)\r\n\t/go/src/github.com/docker/docker/api/server/server.go:901 +0x219\r\ngithub.com/docker/docker/api/server.*Server.(github.com/docker/docker/api/server.postContainersCreate)·fm(0xdb8000, 0x4, 0x7f73d88a2320, 0xc208174be0, 0xc2080f5790, 0xc208409020, 0x0, 0x0)\r\n\t/go/src/github.com/docker/docker/api/server/server.go:1519 +0x7b\r\ngithub.com/docker/docker/api/server.func·008(0x7f73d88a2320, 0xc208174be0, 0xc2080f5790)\r\n\t/go/src/github.com/docker/docker/api/server/server.go:1475 +0x91d\r\nnet/http.HandlerFunc.ServeHTTP(0xc208189a80, 0x7f73d88a2320, 0xc208174be0, 0xc2080f5790)\r\n\t/usr/local/go/src/net/http/server.go:1265 +0x41\r\ngithub.com/gorilla/mux.(*Router).ServeHTTP(0xc2080db1d0, 0x7f73d88a2320, 0xc208174be0, 0xc2080f5790)\r\n\t/go/src/github.com/docker/docker/vendor/src/github.com/gorilla/mux/mux.go:98 +0x297\r\nnet/http.serverHandler.ServeHTTP(0xc208062420, 0x7f73d88a2320, 0xc208174be0, 0xc2080f5790)\r\n\t/usr/local/go/src/net/http/server.go:1703 +0x19a\r\nnet/http.(*conn).serve(0xc208174aa0)\r\n\t/usr/local/go/src/net/http/server.go:1204 +0xb57\r\ncreated by net/http.(*Server).Serve\r\n\t/usr/local/go/src/net/http/server.go:1751 +0x35e\r\n```\r\n\r\nI checked other code paths from `DecodeContainerConfig` and they are safe checking the config against nil\r\nAnyway this api call should return 400 Bad Request instead of 500 IMHO, but I'm seeking opinion about this, ping @duglin @calavera @LK4D4 \r\n\r\nSigned-off-by: Antonio Murdaca <runcom@linux.com>"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/110102584","html_url":"https://github.com/docker/docker/pull/13787#issuecomment-110102584","issue_url":"https://api.github.com/repos/docker/docker/issues/13787","id":110102584,"user":{"login":"jfrazelle","id":1445228,"avatar_url":"https://avatars.githubusercontent.com/u/1445228?v=3","gravatar_id":"","url":"https://api.github.com/users/jfrazelle","html_url":"https://github.com/jfrazelle","followers_url":"https://api.github.com/users/jfrazelle/followers","following_url":"https://api.github.com/users/jfrazelle/following{/other_user}","gists_url":"https://api.github.com/users/jfrazelle/gists{/gist_id}","starred_url":"https://api.github.com/users/jfrazelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfrazelle/subscriptions","organizations_url":"https://api.github.com/users/jfrazelle/orgs","repos_url":"https://api.github.com/users/jfrazelle/repos","events_url":"https://api.github.com/users/jfrazelle/events{/privacy}","received_events_url":"https://api.github.com/users/jfrazelle/received_events","type":"User","site_admin":false},"created_at":"2015-06-08T18:38:25Z","updated_at":"2015-06-08T18:38:25Z","body":"cherry-pciked"}}