JuliusBrussee/caveman · error
( ): trailing PEM block is truncated after certificate(s)…
Error message
%s (%s): trailing PEM block is truncated after %d certificate(s), so the bundle is incomplete and must not be half-trusted
What it means
After decoding all complete PEM blocks in the CA bundle, leftover bytes still contain a BEGIN marker: the final certificate is truncated mid-block. A truncated tail would silently drop an issuer, so the bundle is rejected as incomplete rather than half-trusted.
Solutions
- Restore the full CA bundle — the trailing certificate was cut off
- Fix the secret provisioning pipeline that truncated the mounted bundle
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shared/platform/chhttp/chhttp.go:188 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/a3f101cc3145d6e2.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/chhttp/chhttp.go:188
rest := bundle
for {
var block *pem.Block
block, rest = pem.Decode(rest)
if block == nil {
break
}
if block.Type != "CERTIFICATE" {
continue
}
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, fmt.Errorf("%s (%s): certificate %d is unparseable, so the bundle is incomplete and must not be half-trusted: %w", caFileEnv, path, added+1, err)
}
roots.AddCert(cert)
added++
}
if bytes.Contains(rest, []byte("-----BEGIN")) {
return nil, fmt.Errorf("%s (%s): trailing PEM block is truncated after %d certificate(s), so the bundle is incomplete and must not be half-trusted", caFileEnv, path, added)
}
if added == 0 {
return nil, fmt.Errorf("%s (%s) contains no valid PEM certificate", caFileEnv, path)
}
return roots, nil
}
// errTransport fails every request with the configuration error that produced
// it. A client constructor cannot return an error, and falling back to the
// default transport would silently trade a rejected TLS configuration for
// unpinned verification — so the client is built, and refuses to send.
type errTransport struct{ err error }
func (t errTransport) RoundTrip(*http.Request) (*http.Response, error) { return nil, t.err }
// queryTransport is the shared connection pool behind ClickHouse query clients.
//
// http.DefaultTransport keeps only DefaultMaxIdleConnsPerHost (2) idleView on GitHub (pinned to 766dce6b13)