{"action":"created","issue":{"url":"https://api.github.com/repos/go-kivik/couchdb/issues/79","repository_url":"https://api.github.com/repos/go-kivik/couchdb","labels_url":"https://api.github.com/repos/go-kivik/couchdb/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/go-kivik/couchdb/issues/79/comments","events_url":"https://api.github.com/repos/go-kivik/couchdb/issues/79/events","html_url":"https://github.com/go-kivik/couchdb/issues/79","id":302132830,"number":79,"title":"Errors trying to PUT doc to Cloudant via HTTPS","user":{"login":"tleyden","id":296876,"avatar_url":"https://avatars1.githubusercontent.com/u/296876?v=4","gravatar_id":"","url":"https://api.github.com/users/tleyden","html_url":"https://github.com/tleyden","followers_url":"https://api.github.com/users/tleyden/followers","following_url":"https://api.github.com/users/tleyden/following{/other_user}","gists_url":"https://api.github.com/users/tleyden/gists{/gist_id}","starred_url":"https://api.github.com/users/tleyden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleyden/subscriptions","organizations_url":"https://api.github.com/users/tleyden/orgs","repos_url":"https://api.github.com/users/tleyden/repos","events_url":"https://api.github.com/users/tleyden/events{/privacy}","received_events_url":"https://api.github.com/users/tleyden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-04T23:13:08Z","updated_at":"2018-03-04T23:16:20Z","closed_at":null,"author_association":"NONE","body":"This started happening all of the sudden at Mon, Feb 12, 2018 at 10:00 AM, with no known changes on my end.  I'm not sure if Cloudant changed something on their end.  I filed a support issue with them, but got the response:\r\n\r\n> Can you reproduce the problem using the Cloudant API or any of the supported client libraries that are listed at\r\n https://console.bluemix.net/docs/services/Cloudant/libraries/supported.html#supported-client-libraries    \r\n> There should be no difference in the result of requests whether the protocol used is HTTP or HTTPS.\r\n\r\nAfter digging into it, I'm able to reproduce with this test code:\r\n\r\nhttps://github.com/tleyden/keynuker/blob/18143d259c6711aacf0e4e75af84d5501b143df7/write_doc_test.go#L16-L105\r\n\r\nThe errors in the logs are: https://gist.github.com/tleyden/bde26a0fe25eae17a752d5e636547318 (which includes some log messages that I haven't pushed up to github)\r\n\r\nand I'm on the following commits for the go-kivik driver libraries:\r\n\r\n* go-kivik/couchdb commit b05fce5e384b7a2b51a9dd698065042f66c322d4  Tue Dec 26 15:21:07 2017 +0100 (I later updated to 74d231fe43245e77840213724894264f0f61ffd3)\r\n\r\n* go-kivik/kivik commit d573df18e22d55cffe07dd8dc43c0aac2104b91a Fri Dec 22 19:31:25 2017 +0100 (I later updated to 9f4809d02c708b15465454aeef571901c4f9917b)\r\n\r\nIf I switch to HTTP, with no other changes, the problem goes away.  Here are the logs from that same test after switching to HTTP: https://gist.github.com/tleyden/2c4ec6dbee9d0b4dfa9e606ea647e0e8 \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/go-kivik/couchdb/issues/comments/370273726","html_url":"https://github.com/go-kivik/couchdb/issues/79#issuecomment-370273726","issue_url":"https://api.github.com/repos/go-kivik/couchdb/issues/79","id":370273726,"user":{"login":"tleyden","id":296876,"avatar_url":"https://avatars1.githubusercontent.com/u/296876?v=4","gravatar_id":"","url":"https://api.github.com/users/tleyden","html_url":"https://github.com/tleyden","followers_url":"https://api.github.com/users/tleyden/followers","following_url":"https://api.github.com/users/tleyden/following{/other_user}","gists_url":"https://api.github.com/users/tleyden/gists{/gist_id}","starred_url":"https://api.github.com/users/tleyden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleyden/subscriptions","organizations_url":"https://api.github.com/users/tleyden/orgs","repos_url":"https://api.github.com/users/tleyden/repos","events_url":"https://api.github.com/users/tleyden/events{/privacy}","received_events_url":"https://api.github.com/users/tleyden/received_events","type":"User","site_admin":false},"created_at":"2018-03-04T23:16:20Z","updated_at":"2018-03-04T23:16:20Z","author_association":"NONE","body":"This workaround in https://github.com/go-kivik/couchdb/blob/master/chttp/chttp.go#L166-L185 seems to fix it:\r\n\r\n```\r\n// DoReq does an HTTP request. An error is returned only if there was an error\r\n// processing the request. In particular, an error status code, such as 400\r\n// or 500, does _not_ cause an error to be returned.\r\nfunc (c *Client) DoReq(ctx context.Context, method, path string, opts *Options) (*http.Response, error) {\r\n\tif method == \"\" {\r\n\t\treturn nil, errors.Status(kivik.StatusBadRequest, \"chttp: method required\")\r\n\t}\r\n\tvar body io.Reader\r\n\tif opts != nil {\r\n\t\tif opts.Body != nil {\r\n\t\t\tbody = opts.Body\r\n\t\t}\r\n\t}\r\n\r\n\t// read the whole body into a string\r\n\r\n\tvar destBody io.Reader\r\n\tdestBody = body\r\n\r\n\tif body != nil {\r\n\r\n\t\tentireBody, err := ioutil.ReadAll(body)\r\n\t\tif err != nil {\r\n\t\t\tlog.Printf(\"Error reading body: %v\", err)\r\n\t\t}\r\n\t\tlog.Printf(\"body size: %d bytes\", len(entireBody))\r\n\r\n\t\tbody2 := bytes.NewBuffer(entireBody)\r\n\t\tdestBody = body2\r\n\r\n\t}\r\n\r\n\treq, err := c.NewRequest(ctx, method, path, destBody)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tfixPath(req, path)\r\n\tsetHeaders(req, opts)\r\n\r\n\tresponse, err := c.Do(req)\r\n\treturn response, netError(err)\r\n}\r\n```\r\n\r\nLogs: https://gist.github.com/tleyden/d5f65db9d39e08e581b274515a235442\r\n"}}
{"actor":{"display_login":"tleyden"}}