{"record":{"id":"fced444efeaee751","repo":"siyuan-note/siyuan","slug":"theme-s-not-exists-or-not-available-for-dark-mo","errorCode":null,"errorMessage":"theme [%s] not exists or not available for dark mode","messagePattern":"theme \\[(.+?)\\] not exists or not available for dark mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/appearance.go","lineNumber":96,"sourceCode":"\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\n\t\t\tConf.Appearance.Mode = 1\n\t\tcase \"system\":\n\t\t\tConf.Appearance.ModeOS = true\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"invalid appearance mode: %s\", appearanceMode)","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/appearance.go#L78-L114","documentation":"Returned by SetTheme when modes contains 1 (dark) but the requested theme name is not in Conf.Appearance.DarkThemes. Dark themes are loaded by LoadThemes into the DarkThemes slice; SetTheme checks membership by Name before assigning Conf.Appearance.ThemeDark.","triggerScenarios":"Calling SetTheme with mode 1 and a theme not present among installed dark themes — uninstalled theme, typo, or a light-only theme passed for dark mode.","commonSituations":"A theme pack was uninstalled but config still references it; a theme is light-only and is passed for dark mode; calling before LoadThemes has run.","solutions":["Install the theme pack, or choose a name from Conf.Appearance.DarkThemes (default \"midnight\").","If the theme is light-only, do not include mode 1 in the modes slice for that call.","Call SetTheme only after InitAppearance has loaded themes."],"exampleFix":"// before\nmodel.SetTheme(\"light-only-theme\", []int{0, 1}, \"\")\n// after\nmodel.SetTheme(\"midnight\", []int{1}, \"\")","handlingStrategy":"validation","validationCode":"if !containTheme(name, Conf.Appearance.DarkThemes) {\n    return fmt.Errorf(\"theme %q not installed for dark 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 1 for light-only themes.","Re-validate persisted theme names when a theme pack is uninstalled."],"tags":["appearance","theme","config","dark-mode","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}