{"record":{"id":"f04f5fc5343a45ab","repo":"grafana/k6","slug":"invalid-tls-value-v-expected-optional-keys","errorCode":null,"errorMessage":"invalid tls value: '%#v', expected (optional) keys: cert, key, password, and cacerts","messagePattern":"invalid tls value: '%#v', expected \\(optional\\) keys: cert, key, password, and cacerts","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/grpc/params.go","lineNumber":225,"sourceCode":"\t\t\tvar ok bool\n\t\t\tresult.Authority, ok = v.(string)\n\t\t\tif !ok {\n\t\t\t\treturn result, fmt.Errorf(\"invalid authority value: '%#v', it needs to be a string\", v)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn result, fmt.Errorf(\"unknown connect param: %q\", k)\n\t\t}\n\t}\n\n\treturn result, nil\n}\n\nfunc parseConnectTLSParam(params *connectParams, v any) error {\n\tvar ok bool\n\tparams.TLS, ok = v.(map[string]any)\n\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid tls value: '%#v', expected (optional) keys: cert, key, password, and cacerts\", v)\n\t}\n\t// optional map keys below\n\tif cert, certok := params.TLS[\"cert\"]; certok {\n\t\tif _, ok = cert.(string); !ok {\n\t\t\treturn fmt.Errorf(\"invalid tls cert value: '%#v', it needs to be a PEM formatted string\", v)\n\t\t}\n\t}\n\tif key, keyok := params.TLS[\"key\"]; keyok {\n\t\tif _, ok = key.(string); !ok {\n\t\t\treturn fmt.Errorf(\"invalid tls key value: '%#v', it needs to be a PEM formatted string\", v)\n\t\t}\n\t}\n\tif pass, passok := params.TLS[\"password\"]; passok {\n\t\tif _, ok = pass.(string); !ok {\n\t\t\treturn fmt.Errorf(\"invalid tls password value: '%#v', it needs to be a string\", v)\n\t\t}\n\t}\n\tif cacerts, cacertsok := params.TLS[\"cacerts\"]; cacertsok {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/grpc/params.go#L207-L243","documentation":"Raised by parseConnectTLSParam when the `tls` key of the connect params object passed to grpc.Client.connect() is not a JavaScript object. The function type-asserts the value to map[string]any before looking for the optional cert/key/password/cacerts keys; any other JS type (string, number, array, null) fails the assertion and produces this error. The offending value is echoed with %#v.","triggerScenarios":"Thrown at internal/js/modules/k6/grpc/params.go:225 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an object literal for tls, e.g. client.connect(url, { tls: { cacerts: [pem] } })","Omit the tls key entirely if no custom TLS settings are needed","Ensure you are not accidentally passing a JSON string instead of a parsed object"],"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"}