{"record":{"id":"460cb524a360d8a3","repo":"grafana/k6","slug":"failed-to-load-tls-credentials-from-file-w","errorCode":null,"errorMessage":"failed to load TLS credentials from file: %w","messagePattern":"failed to load TLS credentials from file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/insights/client.go","lineNumber":228,"sourceCode":"\tif cfg.ConnectConfig.Block {\n\t\topts = append(opts, grpc.WithBlock()) //nolint:staticcheck\n\t}\n\n\tif cfg.ConnectConfig.FailOnNonTempDialError {\n\t\topts = append(opts, grpc.FailOnNonTempDialError(true)) //nolint:staticcheck\n\t}\n\n\tif cfg.ConnectConfig.Dialer != nil {\n\t\topts = append(opts, grpc.WithContextDialer(cfg.ConnectConfig.Dialer))\n\t}\n\n\tif cfg.TLSConfig.Insecure { //nolint: nestif\n\t\topts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))\n\t} else {\n\t\tif cfg.TLSConfig.CertFile != \"\" {\n\t\t\tcreds, err := credentials.NewClientTLSFromFile(cfg.TLSConfig.CertFile, \"\")\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to load TLS credentials from file: %w\", err)\n\t\t\t}\n\t\t\topts = append(opts, grpc.WithTransportCredentials(creds))\n\t\t} else {\n\t\t\topts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS13})))\n\t\t}\n\t}\n\n\tif cfg.AuthConfig.Enabled {\n\t\topts = append(opts, grpc.WithPerRPCCredentials(newPerRPCCredentials(cfg.AuthConfig)))\n\t}\n\n\trI, err := retryInterceptor(cfg.RetryConfig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create retry interceptors: %w\", err)\n\t}\n\n\topts = append(opts, grpc.WithChainUnaryInterceptor([]grpc.UnaryClientInterceptor{rI}...))\n","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cloudapi/insights/client.go#L210-L246","documentation":"Wrapped error from dialOptionsFromClientConfig when TLS is not insecure and a cert file is configured: grpc's credentials.NewClientTLSFromFile could not load/parse the file at cfg.TLSConfig.CertFile, so the dial options cannot be built.","triggerScenarios":"Thrown at internal/cloudapi/insights/client.go:228 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the configured cert file path exists and is readable by k6","Verify the file is a valid PEM-encoded certificate","Remove the cert setting to use the system/default TLS roots if appropriate"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}