{"record":{"id":"48db9741627a6c49","repo":"grafana/k6","slug":"unmarshaling-dom-element-state-w","errorCode":null,"errorMessage":"unmarshaling DOM element state: %w","messagePattern":"unmarshaling DOM element state: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":77,"sourceCode":"func DOMElementStateIDFromString(format string) (DOMElementState, bool) {\n\tid, exists := domElementStateToID[format]\n\treturn id, exists\n}\n\n// MarshalJSON marshals the enum as a quoted JSON string.\nfunc (s DOMElementState) MarshalJSON() ([]byte, error) {\n\tbuffer := bytes.NewBufferString(`\"`)\n\tbuffer.WriteString(domElementStateToString[s])\n\tbuffer.WriteString(`\"`)\n\treturn buffer.Bytes(), nil\n}\n\n// UnmarshalJSON unmarshals a quoted JSON string to the enum value.\nfunc (s *DOMElementState) UnmarshalJSON(b []byte) error {\n\tvar j string\n\terr := json.Unmarshal(b, &j)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unmarshaling DOM element state: %w\", err)\n\t}\n\t// Note that if the string cannot be found then it will be set to the zero value.\n\t*s = domElementStateToID[j]\n\treturn nil\n}\n\n// Frame represents a frame in an HTML document.\ntype Frame struct {\n\tBaseEventEmitter\n\n\tctx         context.Context\n\tpage        *Page\n\tmanager     *FrameManager\n\tparentFrame *Frame\n\n\tchildFramesMu sync.RWMutex\n\tchildFrames   map[*Frame]bool\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L59-L95","documentation":"Returned by DOMElementState.UnmarshalJSON when the raw JSON for a DOM element state is not a valid JSON string (e.g. a number, object, or malformed JSON). The state field is expected as a quoted string like \"attached\", \"detached\", \"visible\" or \"hidden\"; anything else fails json.Unmarshal into the string sink.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:72 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the state option as one of the strings: attached, detached, visible, hidden","Do not pass numbers, objects, or unquoted identifiers as state"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}