{"record":{"id":"1656ad026990cc73","repo":"siyuan-note/siyuan","slug":"theme-s-not-exists-or-not-available-for-light-m","errorCode":null,"errorMessage":"theme [%s] not exists or not available for light mode","messagePattern":"theme \\[(.+?)\\] not exists or not available for light mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/appearance.go","lineNumber":91,"sourceCode":"\tdefer Conf.m.Unlock()\n\n\tif !containIcon(icon, Conf.Appearance.Icons) {\n\t\treturn fmt.Errorf(\"icon [%s] not exists or not available\", icon)\n\t}\n\tConf.Appearance.Icon = icon\n\treturn nil\n}\n\nfunc SetTheme(theme string, modes []int, appearanceMode string) error {\n\tConf.m.Lock()\n\tdefer Conf.m.Unlock()\n\n\tif theme != \"\" {\n\t\tfor _, mode := range modes {\n\t\t\tswitch mode {\n\t\t\tcase 0:\n\t\t\t\tif !containTheme(theme, Conf.Appearance.LightThemes) {\n\t\t\t\t\treturn fmt.Errorf(\"theme [%s] not exists or not available for light mode\", theme)\n\t\t\t\t}\n\t\t\t\tConf.Appearance.ThemeLight = theme\n\t\t\tcase 1:\n\t\t\t\tif !containTheme(theme, Conf.Appearance.DarkThemes) {\n\t\t\t\t\treturn fmt.Errorf(\"theme [%s] not exists or not available for dark mode\", theme)\n\t\t\t\t}\n\t\t\t\tConf.Appearance.ThemeDark = theme\n\t\t\t}\n\t\t}\n\t}\n\n\tif appearanceMode != \"\" {\n\t\tswitch appearanceMode {\n\t\tcase \"light\":\n\t\t\tConf.Appearance.ModeOS = false\n\t\t\tConf.Appearance.Mode = 0\n\t\tcase \"dark\":\n\t\t\tConf.Appearance.ModeOS = false","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/appearance.go#L73-L109","documentation":"Returned by SetTheme when modes contains 0 (light) but the requested theme name is not in Conf.Appearance.LightThemes. Light themes are loaded by LoadThemes into the LightThemes slice; SetTheme checks membership by Name before assigning Conf.Appearance.ThemeLight.","triggerScenarios":"Calling SetTheme with mode 0 and a theme not present among installed light themes — uninstalled theme, typo, or a dark-only theme passed for light mode.","commonSituations":"A theme pack was uninstalled but the UI/API still sends its name; a theme is dark-only and the caller passes it for both modes; calling before LoadThemes has run.","solutions":["Install the theme pack, or choose a name from Conf.Appearance.LightThemes (default \"daylight\").","If the theme is dark-only, do not include mode 0 in the modes slice for that call.","Call SetTheme only after InitAppearance has loaded themes."],"exampleFix":"// before\nmodel.SetTheme(\"dark-only-theme\", []int{0, 1}, \"\")\n// after\nmodel.SetTheme(\"daylight\", []int{0}, \"\")","handlingStrategy":"validation","validationCode":"if !containTheme(name, Conf.Appearance.LightThemes) {\n    return fmt.Errorf(\"theme %q not installed for light mode\", name)\n}","typeGuard":"func themeAvailableForMode(name string, themes []*conf.AppearanceTheme) bool {\n    for _, t := range themes { if t.Name == name { return true } }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Call SetTheme only after InitAppearance has loaded themes.","Do not pass mode 0 for dark-only themes.","Re-validate persisted theme names when a theme pack is uninstalled."],"tags":["appearance","theme","config","light-mode","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}