yudai/gotty · error
failed to marshal preferences as JSON
Error message
failed to marshal preferences as JSON
What it means
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.
Source
Thrown at webtty/option.go:57
wt.windowTitle = windowTitle
return nil
}
}
// WithReconnect enables reconnection on the master side.
func WithReconnect(timeInSeconds int) Option {
return func(wt *WebTTY) error {
wt.reconnect = timeInSeconds
return nil
}
}
// WithMasterPreferences sets an optional configuration of master.
func WithMasterPreferences(preferences interface{}) Option {
return func(wt *WebTTY) error {
prefs, err := json.Marshal(preferences)
if err != nil {
return errors.Wrapf(err, "failed to marshal preferences as JSON")
}
wt.masterPrefs = prefs
return nil
}
}
View on GitHub (pinned to a080c85cbc)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at webtty/option.go:57 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of yudai/gotty@a080c85cbc (2026-09-02).
Data as JSON: /api/errors/5135c18276214870.
Report an issue: GitHub.