JuliusBrussee/caveman · error
clickhouse response byte limit must be positive
Error message
clickhouse response byte limit must be positive
What it means
ReadBodyBounded was called with a maxBytes ceiling of zero or less, which cannot bound anything. It is a caller bug (an unset limit variable) — the guard fires before any reading so an unbounded read never happens by accident of a missing limit.
Source
Thrown at shared/platform/chhttp/chhttp.go:51
"strings"
"sync"
"time"
"github.com/JuliusBrussee/caveman/shared/platform/env"
)
const (
defaultInsertTimeoutMS = 5000
defaultQueryTimeoutMS = 30000
)
// ReadBodyBounded reads an HTTP response/error body with a hard byte ceiling.
// It deliberately reads one byte beyond the limit so callers can distinguish a
// truncated body from an exact-limit body and fail closed before parsing or
// logging attacker-controlled content.
func ReadBodyBounded(r io.Reader, maxBytes int64) ([]byte, error) {
if maxBytes <= 0 {
return nil, fmt.Errorf("clickhouse response byte limit must be positive")
}
data, err := io.ReadAll(io.LimitReader(r, maxBytes+1))
if err != nil {
return nil, err
}
if int64(len(data)) > maxBytes {
return nil, fmt.Errorf("clickhouse response exceeds %d byte limit", maxBytes)
}
return data, nil
}
// The TLS knobs. All three are unset by default, in which case the clients keep
// stock net/http behaviour: system roots, hostname verified against the URL host.
const (
// serverNameEnv overrides tls.Config.ServerName. This is the managed-
// ClickHouse cutover case: the private .internal DNS record is dialled while
// the deployment's certificate carries only *.dtwh SANs, so verification must
// run against the name the certificate actually holds. Chain AND hostnameView on GitHub (pinned to 766dce6b13)
Solutions
- Pass a positive byte limit to ReadBodyBounded
- Default the limit variable from config when unset instead of passing 0
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shared/platform/chhttp/chhttp.go:51 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/252e8c79586e5732.
Report an issue: GitHub.