siyuan-note/siyuan · error

theme [ ] not exists or not available for light mode

Error message

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

What it means

SetTheme validates the theme name per requested mode. When mode 0 (light) is included and the theme is not in Conf.Appearance.LightThemes (installed themes usable in light mode), the kernel rejects the call with this error and changes nothing.

Solutions

  1. Verify the theme name matches an installed theme (Settings - Appearance - Theme) and fix the spelling
  2. Install the theme package before setting it, then retry
  3. Only pass mode 0 in modes if the theme actually supports light mode; otherwise use the mode it supports
  4. Read Conf.Appearance.LightThemes to list valid names and choose from it

Example fix

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

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

Trigger: Calling the setAppearance API with a theme parameter and modes containing 0 where the theme is not installed or is registered only as a dark theme.

Common situations: Typo in theme name; theme not installed on this machine; script copies a light/dark theme name across modes; theme marketplace package failed to install so it never appears in LightThemes.

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/1656ad026990cc73. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/appearance.go:91

	defer Conf.m.Unlock()

	if !containIcon(icon, Conf.Appearance.Icons) {
		return fmt.Errorf("icon [%s] not exists or not available", icon)
	}
	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

View on GitHub (pinned to 9f775e8a12)