JuliusBrussee/caveman · critical
production requires an https:// CLICKHOUSE_URL (TLS only)…
Error message
production requires an https:// CLICKHOUSE_URL (TLS only); ClickHouse credentials travel as HTTP Basic and a plaintext endpoint ships them in the clear
What it means
ValidateProduction refuses non-https CLICKHOUSE_URL values when running in production. ClickHouse credentials travel as HTTP Basic auth, so a plaintext endpoint would ship them in the clear; the check enforces TLS-only endpoints at boot so misconfiguration becomes a loud non-zero exit rather than a runtime leak.
Solutions
- Set CLICKHOUSE_URL to an https:// endpoint with a hostname, e.g. https://clickhouse.internal.example.com:8443.
- If TLS terminates at a sidecar/proxy, point CLICKHOUSE_URL at the TLS frontend rather than the plaintext upstream.
- Verify the URL parses and includes scheme+host locally before deploying (url.Parse check or curl the https URL).
- If this fires unexpectedly in what should be staging, fix CAVE_ENV so production gates aren't evaluated.
Example fix
// before CLICKHOUSE_URL=http://clickhouse:8123 // after CLICKHOUSE_URL=https://clickhouse.internal.example.com:8443
Defensive patterns
Strategy: validation
Validate before calling
raw := strings.TrimSpace(os.Getenv("CLICKHOUSE_URL"))
u, err := url.Parse(raw)
if err != nil || !strings.EqualFold(u.Scheme, "https") || u.Hostname() == "" {
return errors.New("CLICKHOUSE_URL must be an absolute https:// URL with a host")
} Try / catch
if err := chhttp.ValidateProduction(logger); err != nil {
if strings.Contains(err.Error(), "https:// CLICKHOUSE_URL") {
logger.Error("plaintext ClickHouse endpoint refused in production", "err", err)
os.Exit(1)
}
return err
} Prevention
- Always include the https:// scheme in CLICKHOUSE_URL across all environments.
- Point prod at the TLS-terminating proxy, never the plaintext upstream port.
- Call ValidateProduction as the first thing in main() so bad config exits before serving.
When it happens
Trigger: Setting CLICKHOUSE_URL=http://clickhouse:8123 (or a schemeless/broken URL) while CAVE_ENV indicates production, then calling chhttp.ValidateProduction(logger).
Common situations: Reusing a local docker-compose http:// URL in a prod deploy; omitting the scheme entirely (CLICKHOUSE_URL=clickhouse:8123); an internal service behind a TLS-terminating proxy where the upstream URL was never switched to https.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
Related errors
- production refuses =true: it disables chain and hostname…
- auth_token: in is ignored — the inbound token is read only…
- ca_bundle
- ca bundle
- cave_gateway_identity_unverified
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/0b93e78ed75bdfe0.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/chhttp/chhttp.go:277
// It refuses, in production, a non-HTTPS CLICKHOUSE_URL (the ClickHouse password
// travels as HTTP Basic, so plaintext ships it in the clear) and any attempt to
// disable certificate verification. It also resolves the TLS configuration
// eagerly so an unreadable or unparseable CA bundle fails the process at boot
// instead of at the first telemetry flush. Outside production it warns — loudly
// and once — when verification has been switched off.
//
// It is NOT guaranteed to run before every client is constructed: control-api
// builds a package-level query client at init (internal/httpapi/chclients.go), so
// that one exists before main calls anything. That ordering is safe rather than
// lucky — a client built from a rejected configuration carries errTransport and
// refuses to send, so the failure is the refusal either way; ValidateProduction's
// job is to turn it into a loud non-zero exit at boot instead of a runtime error.
func ValidateProduction(logger *slog.Logger) error {
if production() {
raw := strings.TrimSpace(env.String("CLICKHOUSE_URL", ""))
parsed, err := url.Parse(raw)
if err != nil || !strings.EqualFold(parsed.Scheme, "https") || parsed.Hostname() == "" {
return fmt.Errorf("production requires an https:// CLICKHOUSE_URL (TLS only); ClickHouse credentials travel as HTTP Basic and a plaintext endpoint ships them in the clear")
}
}
cfg, err := tlsClientConfig()
if err != nil {
return err
}
if cfg != nil && cfg.InsecureSkipVerify && logger != nil {
logger.Warn("ClickHouse TLS certificate verification is DISABLED",
"variable", skipVerifyEnv,
"env", env.String("CAVE_ENV", "local"),
"impact", "telemetry and aggregate queries can be read or forged by any in-path party; never set this in production")
}
return nil
}
View on GitHub (pinned to 3ee70a1026)