{"record":{"id":"219e42a3fa31033c","repo":"grafana/k6","slug":"converting-argument-v-w","errorCode":null,"errorMessage":"converting argument '%v': %w","messagePattern":"converting argument '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/helpers.go","lineNumber":80,"sourceCode":"\t\tcase math.Inf(0):\n\t\t\tunserVal = \"Infinity\"\n\t\tcase math.Inf(-1):\n\t\t\tunserVal = \"-Infinity\"\n\t\tdefault:\n\t\t\tif math.IsNaN(a) {\n\t\t\t\tunserVal = \"NaN\"\n\t\t\t}\n\t\t}\n\n\t\tif unserVal != \"\" {\n\t\t\treturn &cdpruntime.CallArgument{\n\t\t\t\tUnserializableValue: cdpruntime.UnserializableValue(unserVal),\n\t\t\t}, nil\n\t\t}\n\n\t\tb, err := json.Marshal(a)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"converting argument '%v': %w\", arg, err)\n\t\t}\n\n\t\treturn &cdpruntime.CallArgument{Value: b}, err\n\tcase *ElementHandle:\n\t\treturn convertBaseJSHandleTypes(ctx, execCtx, &a.BaseJSHandle)\n\tcase *BaseJSHandle:\n\t\treturn convertBaseJSHandleTypes(ctx, execCtx, a)\n\tdefault:\n\t\tb, err := json.Marshal(a)\n\t\treturn &cdpruntime.CallArgument{Value: b}, err //nolint:wrapcheck\n\t}\n}\n\nfunc call(\n\tctx context.Context, fn func(context.Context, chan any, chan error), timeout time.Duration,\n) (any, error) {\n\tvar (\n\t\tresult   any","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/helpers.go#L62-L98","documentation":"Wrap of a json.Marshal failure in the CDP argument converter: convertArgument serializes a Go-side argument (typically a float) to JSON for a Runtime.callFunctionOn invocation. Special values (Infinity, NaN) are handled as UnserializableValue beforehand, so reaching this wrap means the remaining value could not be marshaled — e.g., a float that overflows JSON representation, or an internal type json.Marshal cannot encode. The '%v' shows the offending argument.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/helpers.go:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass finite numeric values to evaluate/handle methods","Check for computed values that became Inf or NaN through division by zero and handle them explicitly","Convert exotic types to plain strings or numbers before passing them to browser evaluate calls"],"exampleFix":null,"handlingStrategy":"try-catch","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"}