{"record":{"id":"470402ed8b90a1ea","repo":"grafana/k6","slug":"invalid-ws-connect-metric-tags-w","errorCode":null,"errorMessage":"invalid ws.connect() metric tags: %w","messagePattern":"invalid ws\\.connect\\(\\) metric tags: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/ws/ws.go","lineNumber":675,"sourceCode":"\t// Parse the optional second argument (params)\n\tparams := paramsV.ToObject(rt)\n\tfor _, k := range params.Keys() {\n\t\tswitch k {\n\t\tcase \"headers\":\n\t\t\theadersV := params.Get(k)\n\t\t\tif common.IsNullish(headersV) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\theadersObj := headersV.ToObject(rt)\n\t\t\tif headersObj == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor _, key := range headersObj.Keys() {\n\t\t\t\tparsedArgs.headers.Set(key, headersObj.Get(key).String())\n\t\t\t}\n\t\tcase \"tags\":\n\t\t\tif err := common.ApplyCustomUserTags(rt, parsedArgs.tagsAndMeta, params.Get(k)); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid ws.connect() metric tags: %w\", err)\n\t\t\t}\n\t\tcase \"jar\":\n\t\t\tjarV := params.Get(k)\n\t\t\tif common.IsNullish(jarV) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif v, ok := jarV.Export().(*httpModule.CookieJar); ok {\n\t\t\t\tparsedArgs.cookieJar = v.Jar\n\t\t\t}\n\t\tcase \"compression\":\n\t\t\t// deflate compression algorithm is supported - as defined in RFC7692\n\t\t\t// compression here relies on the implementation in gorilla/websocket package, usage is\n\t\t\t// experimental and may result in decreased performance. package supports\n\t\t\t// only \"no context takeover\" scenario\n\n\t\t\talgoString := strings.TrimSpace(params.Get(k).ToString().String())\n\t\t\tif algoString == \"\" {\n\t\t\t\tcontinue","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/ws/ws.go#L657-L693","documentation":"The `tags` option passed in the params object of ws.connect() failed to apply. common.ApplyUserTags expects a plain object of string tag name/value pairs; it fires when tags is not an object, a tag value is not a string or convertible to one, or a tag name is empty/invalid. The connection is never attempted — argument parsing aborts.","triggerScenarios":"Thrown at internal/js/modules/k6/ws/ws.go:675 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass tags as a plain object of string keys to string values, e.g. ws.connect(url, { tags: { name: 'myws' } })","Do not pass arrays, numbers, or nested objects as tag values; convert them to strings first","If computing tags dynamically, guard that the value is neither null nor undefined before building the tags 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":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}