{"record":{"id":"65aa56849eb7dcd4","repo":"grafana/k6","slug":"unmarshaling-q-to-lifecycle-event-w","errorCode":null,"errorMessage":"unmarshaling %q to lifecycle event: %w","messagePattern":"unmarshaling %q to lifecycle event: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/lifecycle.go","lineNumber":63,"sourceCode":"\t\"load\":             LifecycleEventLoad,\n\t\"domcontentloaded\": LifecycleEventDOMContentLoad,\n\t\"networkidle\":      LifecycleEventNetworkIdle,\n}\n\n// MarshalJSON marshals the enum as a quoted JSON string.\nfunc (l LifecycleEvent) MarshalJSON() ([]byte, error) {\n\tbuffer := bytes.NewBufferString(`\"`)\n\tbuffer.WriteString(lifecycleEventToString[l])\n\tbuffer.WriteString(`\"`)\n\treturn buffer.Bytes(), nil\n}\n\n// UnmarshalJSON unmarshals a quoted JSON string to the enum value.\nfunc (l *LifecycleEvent) UnmarshalJSON(b []byte) error {\n\tvar j string\n\terr := json.Unmarshal(b, &j)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unmarshaling %q to lifecycle event: %w\", b, err)\n\t}\n\t// Note that if the string cannot be found then it will be set to the zero value.\n\t*l = lifecycleEventToID[j]\n\treturn nil\n}\n\n// MarshalText returns the string representation of the enum value.\n// It returns an error if the enum value is invalid.\nfunc (l *LifecycleEvent) MarshalText() ([]byte, error) {\n\tif l == nil {\n\t\treturn []byte(\"\"), nil\n\t}\n\tvar (\n\t\tok bool\n\t\ts  string\n\t)\n\tif s, ok = lifecycleEventToString[*l]; !ok {\n\t\treturn nil, fmt.Errorf(\"invalid lifecycle event: %v\", int(*l))","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/lifecycle.go#L45-L81","documentation":"Error \"unmarshaling %q to lifecycle event: %w\" thrown in grafana/k6.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/lifecycle.go:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}