{"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":"exception","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/9f775e8a12daef8255556097396f9b2739078892/kernel/model/appearance.go#L78-L114","documentation":"SetTheme validates the theme name per requested mode. When mode 1 (dark) is included and the theme is not in Conf.Appearance.DarkThemes (installed themes usable in dark mode), the kernel rejects the call with this error and changes nothing.","triggerScenarios":"Calling the setAppearance API with a theme parameter and modes containing 1 where the theme is not installed or is registered only as a light theme.","commonSituations":"Typo in theme name; theme package missing on this machine; automation passing a light-only theme name for dark mode; theme not re-registered after an update.","solutions":["Verify the theme name against installed themes (Settings - Appearance - Theme) and correct it","Install the theme package first, then retry the call","Pass only modes the theme supports; for a light-only theme drop mode 1 from modes","List Conf.Appearance.DarkThemes and pick a valid name"],"exampleFix":"// before\nSetTheme(\"daylight\", []int{1}, \"dark\") // daylight is light-only\n// after\nSetTheme(\"midnight\", []int{1}, \"dark\")","handlingStrategy":"validation","validationCode":"const conf = await fetchPost(\"/api/setting/getAppearance\", {});\nif (modes.includes(1) && !conf.darkThemes.some(t => t.name === theme)) throw new Error(`theme ${theme} unavailable for dark mode`);","typeGuard":null,"tryCatchPattern":"try {\n  await setTheme(theme, modes, mode);\n} catch (e) {\n  if (String(e).includes(\"not available for dark mode\")) {\n    // choose from darkThemes or drop mode 1\n  }\n}","preventionTips":["Validate theme names against the installed darkThemes list before calling","Only request modes a theme actually supports","Install theme packages before applying them","Keep theme names in a verified constants file, not inline strings"],"tags":["appearance","theme","invalid-value","config"],"backgroundTag":"resource-not-found","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}