siyuan-note/siyuan · error

theme [ ] not exists or not available for dark mode

Error message

theme [%s] not exists or not available for dark mode

What it means

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.

Solutions

  1. Verify the theme name against installed themes (Settings - Appearance - Theme) and correct it
  2. Install the theme package first, then retry the call
  3. Pass only modes the theme supports; for a light-only theme drop mode 1 from modes
  4. List Conf.Appearance.DarkThemes and pick a valid name

Example fix

// before
SetTheme("daylight", []int{1}, "dark") // daylight is light-only
// after
SetTheme("midnight", []int{1}, "dark")
Defensive patterns

Strategy: validation

Validate before calling

const conf = await fetchPost("/api/setting/getAppearance", {});
if (modes.includes(1) && !conf.darkThemes.some(t => t.name === theme)) throw new Error(`theme ${theme} unavailable for dark mode`);

Try / catch

try {
  await setTheme(theme, modes, mode);
} catch (e) {
  if (String(e).includes("not available for dark mode")) {
    // choose from darkThemes or drop mode 1
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/fced444efeaee751. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/appearance.go:96

	Conf.Appearance.Icon = icon
	return nil
}

func SetTheme(theme string, modes []int, appearanceMode string) error {
	Conf.m.Lock()
	defer Conf.m.Unlock()

	if theme != "" {
		for _, mode := range modes {
			switch mode {
			case 0:
				if !containTheme(theme, Conf.Appearance.LightThemes) {
					return fmt.Errorf("theme [%s] not exists or not available for light mode", theme)
				}
				Conf.Appearance.ThemeLight = theme
			case 1:
				if !containTheme(theme, Conf.Appearance.DarkThemes) {
					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)

View on GitHub (pinned to 9f775e8a12)