{"record":{"id":"a3f101cc3145d6e2","repo":"JuliusBrussee/caveman","slug":"s-s-trailing-pem-block-is-truncated-after-d","errorCode":null,"errorMessage":"%s (%s): trailing PEM block is truncated after %d certificate(s), so the bundle is incomplete and must not be half-trusted","messagePattern":"(.+?) \\((.+?)\\): trailing PEM block is truncated after (.+?) certificate\\(s\\), so the bundle is incomplete and must not be half-trusted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/chhttp/chhttp.go","lineNumber":188,"sourceCode":"\trest := bundle\n\tfor {\n\t\tvar block *pem.Block\n\t\tblock, rest = pem.Decode(rest)\n\t\tif block == nil {\n\t\t\tbreak\n\t\t}\n\t\tif block.Type != \"CERTIFICATE\" {\n\t\t\tcontinue\n\t\t}\n\t\tcert, err := x509.ParseCertificate(block.Bytes)\n\t\tif err != nil {\n\t\t\treturn 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)\n\t\t}\n\t\troots.AddCert(cert)\n\t\tadded++\n\t}\n\tif bytes.Contains(rest, []byte(\"-----BEGIN\")) {\n\t\treturn 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)\n\t}\n\tif added == 0 {\n\t\treturn nil, fmt.Errorf(\"%s (%s) contains no valid PEM certificate\", caFileEnv, path)\n\t}\n\treturn roots, nil\n}\n\n// errTransport fails every request with the configuration error that produced\n// it. A client constructor cannot return an error, and falling back to the\n// default transport would silently trade a rejected TLS configuration for\n// unpinned verification — so the client is built, and refuses to send.\ntype errTransport struct{ err error }\n\nfunc (t errTransport) RoundTrip(*http.Request) (*http.Response, error) { return nil, t.err }\n\n// queryTransport is the shared connection pool behind ClickHouse query clients.\n//\n// http.DefaultTransport keeps only DefaultMaxIdleConnsPerHost (2) idle","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/shared/platform/chhttp/chhttp.go#L170-L206","documentation":"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.","triggerScenarios":"Thrown at shared/platform/chhttp/chhttp.go:188 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the full CA bundle — the trailing certificate was cut off","Fix the secret provisioning pipeline that truncated the mounted bundle"],"exampleFix":null,"handlingStrategy":"validation","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-23T08:17:48.524Z"}