{"record":{"id":"9c61bd1efd17f092","repo":"grafana/k6","slug":"unmarshaling-q-to-colorscheme-w","errorCode":null,"errorMessage":"unmarshaling %q to ColorScheme: %w","messagePattern":"unmarshaling %q to ColorScheme: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":171,"sourceCode":"\t\"light\":         ColorSchemeLight,\n\t\"dark\":          ColorSchemeDark,\n\t\"no-preference\": ColorSchemeNoPreference,\n}\n\n// MarshalJSON marshals the enum as a quoted JSON string.\nfunc (c ColorScheme) MarshalJSON() ([]byte, error) {\n\tbuffer := bytes.NewBufferString(`\"`)\n\tbuffer.WriteString(colorSchemeToString[c])\n\tbuffer.WriteString(`\"`)\n\treturn buffer.Bytes(), nil\n}\n\n// UnmarshalJSON unmarshals a quoted JSON string to the enum value.\nfunc (c *ColorScheme) 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 ColorScheme: %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*c = colorSchemeToID[j]\n\treturn nil\n}\n\n// EmulatedSize represents the emulated viewport and screen sizes.\ntype EmulatedSize struct {\n\tViewport Viewport\n\tScreen   Screen\n}\n\n// NewEmulatedSize creates and returns a new EmulatedSize.\nfunc NewEmulatedSize(viewport Viewport, screen Screen) *EmulatedSize {\n\treturn &EmulatedSize{\n\t\tViewport: viewport,\n\t\tScreen:   screen,\n\t}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L153-L189","documentation":"Failure while decoding the JSON value of a 'colorScheme' browser-context option into the ColorScheme enum. The input at fault is the raw JSON token: it is either not a string, or a string outside the accepted set ('light', 'dark', 'no-preference').","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:169 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use 'light', 'dark', or 'no-preference' for colorScheme","Quote the value — it must be a JSON string, not a bare token or number","Validate externally sourced options before browser context creation"],"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"}