{"record":{"id":"1109906025469559","repo":"grafana/k6","slug":"failed-to-load-client-certificate-w","errorCode":null,"errorMessage":"failed to load client certificate: %w","messagePattern":"failed to load client certificate: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/opentelemetry/tls.go","lineNumber":47,"sourceCode":"\t\tb, err := os.ReadFile(certPath.String) //nolint:forbidigo\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read root certificate from %q: %w\", certPath.String, err)\n\t\t}\n\n\t\tcp := x509.NewCertPool()\n\t\tif ok := cp.AppendCertsFromPEM(b); !ok {\n\t\t\treturn nil, errors.New(\"failed to append root certificate to the pool\")\n\t\t}\n\n\t\ttlsConfig.RootCAs = cp\n\t\tset = true\n\t}\n\n\t// Load the client certificate\n\tif clientCertPath.Valid {\n\t\tcert, err := tls.LoadX509KeyPair(clientCertPath.String, clientKeyPath.String)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load client certificate: %w\", err)\n\t\t}\n\n\t\ttlsConfig.Certificates = []tls.Certificate{cert}\n\t\tset = true\n\t}\n\n\tif !set {\n\t\treturn nil, nil //nolint:nilnil // no TLS config set\n\t}\n\n\treturn tlsConfig, nil\n}\n","sourceCodeStart":29,"sourceCodeEnd":60,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/output/opentelemetry/tls.go#L29-L60","documentation":"When client certificate options are configured, buildTLSConfig calls tls.LoadX509KeyPair with the client cert and key paths; this error wraps that failure — files unreadable, not PEM-encoded, or cert/key mismatch. The mTLS configuration is invalid so the OpenTelemetry exporter is not created.","triggerScenarios":"Thrown at internal/output/opentelemetry/tls.go:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that both cert and key file paths exist and are readable","Ensure the certificate and key are a valid PEM pair","Regenerate the client certificate/key if corrupted"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}