{"record":{"id":"be2a81dc81f2866c","repo":"JuliusBrussee/caveman","slug":"clickhouse-response-exceeds-d-byte-limit","errorCode":null,"errorMessage":"clickhouse response exceeds %d byte limit","messagePattern":"clickhouse response exceeds (.+?) byte limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/chhttp/chhttp.go","lineNumber":58,"sourceCode":"const (\n\tdefaultInsertTimeoutMS = 5000\n\tdefaultQueryTimeoutMS  = 30000\n)\n\n// ReadBodyBounded reads an HTTP response/error body with a hard byte ceiling.\n// It deliberately reads one byte beyond the limit so callers can distinguish a\n// truncated body from an exact-limit body and fail closed before parsing or\n// logging attacker-controlled content.\nfunc ReadBodyBounded(r io.Reader, maxBytes int64) ([]byte, error) {\n\tif maxBytes <= 0 {\n\t\treturn nil, fmt.Errorf(\"clickhouse response byte limit must be positive\")\n\t}\n\tdata, err := io.ReadAll(io.LimitReader(r, maxBytes+1))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif int64(len(data)) > maxBytes {\n\t\treturn nil, fmt.Errorf(\"clickhouse response exceeds %d byte limit\", maxBytes)\n\t}\n\treturn data, nil\n}\n\n// The TLS knobs. All three are unset by default, in which case the clients keep\n// stock net/http behaviour: system roots, hostname verified against the URL host.\nconst (\n\t// serverNameEnv overrides tls.Config.ServerName. This is the managed-\n\t// ClickHouse cutover case: the private .internal DNS record is dialled while\n\t// the deployment's certificate carries only *.dtwh SANs, so verification must\n\t// run against the name the certificate actually holds. Chain AND hostname\n\t// verification stay fully enforced — only the name being matched changes.\n\tserverNameEnv = \"CLICKHOUSE_TLS_SERVER_NAME\"\n\t// caFileEnv is a path to a PEM bundle APPENDED to the system roots (a private\n\t// CA is trusted in addition to, never instead of, the public ones).\n\tcaFileEnv = \"CLICKHOUSE_TLS_CA_FILE\"\n\t// skipVerifyEnv disables chain and hostname verification. Production refuses\n\t// it outright; outside production it is honoured with a startup warning.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/shared/platform/chhttp/chhttp.go#L40-L76","documentation":"The ClickHouse HTTP response body exceeded the configured byte ceiling; the helper reads maxBytes+1 to distinguish over-limit from exact-limit and fails closed before parsing or logging attacker-controlled content. It signals either a misbehaving endpoint or a limit set below legitimate payload size.","triggerScenarios":"Thrown at shared/platform/chhttp/chhttp.go:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Raise the response byte limit if legitimate payloads are larger","Investigate the endpoint if responses are unexpectedly huge — it may be returning an error page or garbage"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}