siyuan-note/siyuan · error
invalid appearance mode: %s
Error message
invalid appearance mode: %s
What it means
Returned by SetTheme when appearanceMode is non-empty but not one of the accepted literals "light", "dark", or "system". SetTheme switches on these three values to set ModeOS and Mode; any other string (typos, localized values, "auto", "Light") falls through to the default branch and is rejected.
Source
Thrown at kernel/model/appearance.go:114
return fmt.Errorf("theme [%s] not exists or not available for dark mode", theme)
}
Conf.Appearance.ThemeDark = theme
}
}
}
if appearanceMode != "" {
switch appearanceMode {
case "light":
Conf.Appearance.ModeOS = false
Conf.Appearance.Mode = 0
case "dark":
Conf.Appearance.ModeOS = false
Conf.Appearance.Mode = 1
case "system":
Conf.Appearance.ModeOS = true
default:
return fmt.Errorf("invalid appearance mode: %s", appearanceMode)
}
}
return nil
}
func containTheme(name string, themes []*conf.AppearanceTheme) bool {
for _, t := range themes {
if t.Name == name {
return true
}
}
return false
}
func containIcon(name string, icons []*conf.AppearanceIcon) bool {
for _, i := range icons {
if i.Name == name {
return trueView on GitHub (pinned to 251596fc0d)
Solutions
- Pass exactly "light", "dark", or "system" (lowercase, no whitespace).
- Trim and lowercase the value before calling SetTheme if it originates from user input.
- Pass an empty string to leave the appearance mode unchanged.
Example fix
// before
model.SetTheme("daylight", []int{0}, "Light ")
// after
mode := strings.ToLower(strings.TrimSpace("Light "))
model.SetTheme("daylight", []int{0}, mode) // "light" Defensive patterns
Strategy: validation
Validate before calling
switch strings.ToLower(strings.TrimSpace(appearanceMode)) {
case "", "light", "dark", "system":
default:
return fmt.Errorf("invalid appearance mode: %s", appearanceMode)
} Type guard
func validAppearanceMode(mode string) bool {
switch mode {
case "", "light", "dark", "system": return true
}
return false
} Prevention
- Normalize mode input: trim whitespace and lowercase before calling SetTheme.
- Pass an empty string to leave the mode unchanged.
- Use the canonical literals light/dark/system; avoid localized or capitalized variants.
When it happens
Trigger: Calling SetTheme with an appearanceMode such as "auto", "Light", "day", or any non-English/localized word; passing an uppercase variant; trailing whitespace in the value.
Common situations: A client sends a localized or capitalized mode string; a typo; whitespace from user input not trimmed; confusion with theme-mode integers (passing "0"/"1" instead of "light"/"dark").
Related errors
- invalid new item template field value mode [%s]
- icon [%s] not exists or not available
- theme [%s] not exists or not available for light mode
- theme [%s] not exists or not available for dark mode
- unsupported OIDC provider [%s]
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/2bad57dca05c7ede.
Report an issue: GitHub.