{"record":{"id":"5135c18276214870","repo":"yudai/gotty","slug":"failed-to-marshal-preferences-as-json","errorCode":null,"errorMessage":"failed to marshal preferences as JSON","messagePattern":"failed to marshal preferences as JSON","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"webtty/option.go","lineNumber":57,"sourceCode":"\t\twt.windowTitle = windowTitle\n\t\treturn nil\n\t}\n}\n\n// WithReconnect enables reconnection on the master side.\nfunc WithReconnect(timeInSeconds int) Option {\n\treturn func(wt *WebTTY) error {\n\t\twt.reconnect = timeInSeconds\n\t\treturn nil\n\t}\n}\n\n// WithMasterPreferences sets an optional configuration of master.\nfunc WithMasterPreferences(preferences interface{}) Option {\n\treturn func(wt *WebTTY) error {\n\t\tprefs, err := json.Marshal(preferences)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to marshal preferences as JSON\")\n\t\t}\n\t\twt.masterPrefs = prefs\n\t\treturn nil\n\t}\n}\n","sourceCodeStart":39,"sourceCodeEnd":63,"githubUrl":"https://github.com/yudai/gotty/blob/a080c85cbc59226c94c6941ad8c395232d72d517/webtty/option.go#L39-L63","documentation":"Wrapped json.Marshal error inside the WithMasterPreferences option: the preferences value passed by the server (xterm.js preferences) is not JSON-serializable — e.g. contains channels, funcs, or cyclic structures — so the option rejects itself and aborts webtty.New.","triggerScenarios":"Thrown at webtty/option.go:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a plain map/struct of JSON-compatible types as preferences","Marshal the preferences once at config load to catch bad types early","Reject unsupported preference types at the config layer with a clear message"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a080c85cbc59226c94c6941ad8c395232d72d517","analyzedAt":"2026-09-02T16:42:38.150Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}