{"record":{"id":"8bffc71eb2f290f4","repo":"grafana/k6","slug":"extracting-json-value-remote-object-id-v-w","errorCode":null,"errorMessage":"extracting json value (remote object id: %v): %w","messagePattern":"extracting json value \\(remote object id: (.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/js_handle.go","lineNumber":208,"sourceCode":"}\n\n// JSONValue returns a JSON version of this JS handle.\nfunc (h *BaseJSHandle) JSONValue() (string, error) {\n\tremoteObject := h.remoteObject\n\tif remoteObject.ObjectID != \"\" {\n\t\tvar err error\n\t\taction := runtime.CallFunctionOn(\"function() { return this; }\").\n\t\t\tWithReturnByValue(true).\n\t\t\tWithAwaitPromise(true).\n\t\t\tWithObjectID(h.remoteObject.ObjectID)\n\t\tif remoteObject, _, err = action.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"retrieving json value: %w\", err)\n\t\t}\n\t}\n\n\tres, err := parseConsoleRemoteObject(h.logger, remoteObject)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"extracting json value (remote object id: %v): %w\", remoteObject.ObjectID, err)\n\t}\n\n\treturn res, nil\n}\n\n// ObjectID returns the remote object ID.\nfunc (h *BaseJSHandle) ObjectID() runtime.RemoteObjectID {\n\treturn h.remoteObject.ObjectID\n}\n","sourceCodeStart":190,"sourceCodeEnd":218,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/js_handle.go#L190-L218","documentation":"Wrap of parseConsoleRemoteObject in BaseJSHandle.JSONValue: after the remote object is (optionally) fetched by value, it must be decoded from the CDP RemoteObject representation into a JSON string. This wrap fires when that decoding step fails — the remote object's type/shape is one the parser cannot convert (e.g., a symbol, function, or undefined value), with the remote object ID included for debugging.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/js_handle.go:208 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use jsonValue() only on handles wrapping serializable data (objects, arrays, primitives)","For non-serializable values, evaluate a custom page function that returns a string representation instead","Re-fetch the handle if the remote object may have been released"],"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"}