{"record":{"id":"277de817a1ab6def","repo":"grafana/k6","slug":"unmarshaling-q-to-reducedmotion-w","errorCode":null,"errorMessage":"unmarshaling %q to ReducedMotion: %w","messagePattern":"unmarshaling %q to ReducedMotion: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":119,"sourceCode":"var reducedMotionToID = map[string]ReducedMotion{\n\t\"reduce\":        ReducedMotionReduce,\n\t\"no-preference\": ReducedMotionNoPreference,\n}\n\n// MarshalJSON marshals the enum as a quoted JSON string.\nfunc (r ReducedMotion) MarshalJSON() ([]byte, error) {\n\tbuffer := bytes.NewBufferString(`\"`)\n\tbuffer.WriteString(reducedMotionToString[r])\n\tbuffer.WriteString(`\"`)\n\treturn buffer.Bytes(), nil\n}\n\n// UnmarshalJSON unmarshals a quoted JSON string to the enum value.\nfunc (r *ReducedMotion) 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 ReducedMotion: %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*r = reducedMotionToID[j]\n\treturn nil\n}\n\n// Screen represents a device screen.\ntype Screen struct {\n\tWidth  int64 `js:\"width\"`\n\tHeight int64 `js:\"height\"`\n}\n\n// ColorScheme represents a browser color scheme.\ntype ColorScheme string\n\n// Valid color schemes.\nconst (\n\tColorSchemeLight        ColorScheme = \"light\"","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L101-L137","documentation":"Failure while decoding the JSON value of a 'reducedMotion' browser-context option into the ReducedMotion enum. The input at fault is the raw JSON token: either it is not a JSON string at all, or the string is not one of the known values ('reduce', 'no-preference').","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:117 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass reducedMotion as one of the strings 'reduce' or 'no-preference'","Do not pass an enum as a number or object — the decoder expects a quoted string","Validate script/CLI-provided options before constructing the browser context"],"exampleFix":null,"handlingStrategy":"type-guard","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"}