{"record":{"id":"6172c07d2f931e1d","repo":"grafana/k6","slug":"json-couldn-t-be-parsed-w","errorCode":null,"errorMessage":"json couldn't be parsed: %w","messagePattern":"json couldn't be parsed: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_session.go","lineNumber":355,"sourceCode":"}\n\nfunc (fs *FrameSession) parseAndEmitWebVitalMetric(object string) error {\n\tfs.logger.Debugf(\"FrameSession:parseAndEmitWebVitalMetric\", \"object:%s\", object)\n\n\twv := struct {\n\t\tID             string\n\t\tName           string\n\t\tValue          json.Number\n\t\tRating         string\n\t\tDelta          json.Number\n\t\tNumEntries     json.Number\n\t\tNavigationType string\n\t\tURL            string\n\t\tSpanID         string\n\t}{}\n\n\tif err := json.Unmarshal([]byte(object), &wv); err != nil {\n\t\treturn fmt.Errorf(\"json couldn't be parsed: %w\", err)\n\t}\n\n\tmetric, ok := fs.k6Metrics.WebVitals[wv.Name]\n\tif !ok {\n\t\treturn fmt.Errorf(\"metric not registered %q\", wv.Name)\n\t}\n\n\tvalue, err := wv.Value.Float64()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"value couldn't be parsed %q\", wv.Value)\n\t}\n\n\tstate := fs.vu.State()\n\ttags := state.Tags.GetCurrentValues().Tags\n\tif state.Options.SystemTags.Has(k6metrics.TagURL) {\n\t\ttags = handleURLTag(fs.page, wv.URL, http.MethodGet, tags)\n\t}\n","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/grafana/k6/blob/94169daab29df52c1ed2ee0549657a577666b855/internal/js/modules/k6/browser/common/frame_session.go#L337-L373","documentation":"parseAndEmitWebVitalMetric could not json.Unmarshal the string received from the page's web-vitals binding into the expected structure. The payload from the browser didn't match the expected JSON shape — an internal contract mismatch between the injected web-vitals script and k6.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame_session.go:355 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Update k6 — the injected web-vitals script and parser must stay in sync","Report to grafana/k6 if it persists, including the page URL","Retry; corrupted payloads under heavy load are rare but possible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94169daab29df52c1ed2ee0549657a577666b855","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}