clickhouse-go icon indicating copy to clipboard operation
clickhouse-go copied to clipboard

Misleading error when making first connection using incorrect credentials to HTTP/S endpoint

Open RoryCrispin opened this issue 1 year ago • 2 comments

The error failed to read the response: read: read next block: data size should be 0 < 980316009 < 134217728 is returned when executing the first query to a database over HTTP/S if the crendentials are incorrect.

This error is encountered when conn_http.go executeRequest calls msg, err := h.readRawResponse(resp)

The status code should be returned in addition to any errors from readRawResponse.

RoryCrispin avatar Sep 07 '23 17:09 RoryCrispin

We can introduce something like this:

type UnhandledHTTPResponseError {
  Response *http.Response
}

func (e *UnhandledHTTPResponseError) Error() string {
  return fmt.Sprintf("unhandled HTTP %d response received: %s, e.Response.StatusCode, ...)
}

and return it as an error value if the client wasn't able to read the response.

jkaflik avatar Sep 07 '23 17:09 jkaflik

Agreed, sounds like a neat solution

RoryCrispin avatar Sep 11 '23 10:09 RoryCrispin