{"record":{"id":"045175513824231b","repo":"grafana/k6","slug":"unable-to-serialise-request-object-w","errorCode":null,"errorMessage":"unable to serialise request object: %w","messagePattern":"unable to serialise request object: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/grpc/client.go","lineNumber":424,"sourceCode":"\tif p.Timeout == time.Duration(0) {\n\t\tp.Timeout = 2 * time.Minute\n\t}\n\n\tif req == nil {\n\t\treturn grpcReq, errors.New(\"request cannot be nil\")\n\t}\n\n\tobject := req.ToObject(c.vu.Runtime())\n\n\tvar stack []*sobek.Object\n\tnormalized, err := normalizeNumberStrings(object, c.vu.Runtime(), stack)\n\tif err != nil {\n\t\treturn grpcReq, fmt.Errorf(\"unable to normalize number strings: %w\", err)\n\t}\n\n\tb, err := normalized.ToObject(c.vu.Runtime()).MarshalJSON()\n\tif err != nil {\n\t\treturn grpcReq, fmt.Errorf(\"unable to serialise request object: %w\", err)\n\t}\n\n\tp.SetSystemTags(state, c.addr, method)\n\n\treturn grpcext.InvokeRequest{\n\t\tMethod:                 method,\n\t\tMethodDescriptor:       methodDesc,\n\t\tTimeout:                p.Timeout,\n\t\tDiscardResponseMessage: p.DiscardResponseMessage,\n\t\tMessage:                b,\n\t\tTagsAndMeta:            &p.TagsAndMeta,\n\t\tMetadata:               p.Metadata,\n\t}, nil\n}\n\n// normalizeNumberStrings recursively traverses a sobek.Value. It creates a deep copy of any\n// objects or arrays, and converts special float values (NaN, Infinity) to their\n// string representations for proper JSON serialization.","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/grpc/client.go#L406-L442","documentation":"Raised in buildInvokeRequest when MarshalJSON fails on the normalized request object — the payload contains values sobek cannot serialize to JSON (functions, unserializable native objects, cyclic structures).","triggerScenarios":"Thrown at internal/js/modules/k6/grpc/client.go:393 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep the request payload to plain JSON-serializable values","Remove functions, Symbols, or cyclic references from the request","Convert binary fields to the appropriate representation before invoking"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}