siyuan-note/siyuan · error

invalid light theme of

Error message

invalid light theme of %s: %w

What it means

When the light theme object of a builtin color/style fails normalizeInlineStyleTheme, the pair normalizer wraps the inner error ('invalid color: color [...] must use #RRGGBB format' or the backgroundColor variant) with this prefix. The color values must be lowercase-normalizable #RRGGBB hex strings or empty.

Solutions

  1. Convert the light theme color to #RRGGBB hex form (e.g. red -> #ff0000, #fff -> #ffffff)
  2. Check both color and backgroundColor fields in the light theme; the wrapped error names which one is bad
  3. Apply the same fix to the dark theme to avoid the sibling 'invalid dark theme' error
  4. Reload the workspace to confirm the palette loads

Example fix

// before
"light": {"backgroundColor": "#fff"}
// after
"light": {"backgroundColor": "#ffffff"}
Defensive patterns

Strategy: validation

Validate before calling

const HEX = /^#[0-9a-fA-F]{6}$/;
for (const entry of (cfg.builtin?.colors ?? [])) {
  for (const f of ['color', 'backgroundColor']) {
    const v = entry.light?.[f];
    if (v && !HEX.test(v)) throw new Error(`builtin color [${entry.index}] light.${f} '${v}' must use #RRGGBB format`);
  }
}

Type guard

function isHexColor(v) { return v === undefined || v === '' || /^#[0-9a-fA-F]{6}$/.test(v); }

Try / catch

if _, err := setInlineStylesData(styles, currentAV); err != nil {
    if strings.Contains(err.Error(), "invalid light theme") { /* convert the reported color to #RRGGBB and retry */ }
    return err
}

Prevention

When it happens

Trigger: A builtin entry's light.color or light.backgroundColor in inline-styles.json is not a 6-digit hex value (e.g. 'red', '#fff', '#FF00GG', 'rgb(255,0,0)').

Common situations: Pasting CSS color names or rgb()/hsl() values into the JSON; using 3-digit shorthand hex; typos in hex digits; themes copied from other apps with different color formats.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/inline_style.go:796

	if palette == nil {
		return ret, nil
	}
	colors, err := av.NormalizeAttributeViewCustomColors(palette.Colors, strict)
	if err != nil {
		return nil, err
	}
	ret.Colors = colors
	ret.Order = av.NormalizeAttributeViewColorOrder(palette.Order, colors)
	return ret, nil
}

func normalizeInlineStyleThemePair(light, dark *InlineStyleTheme, description string) (normalizedLight,
	normalizedDark *InlineStyleTheme, err error) {
	if light == nil || dark == nil {
		return nil, nil, fmt.Errorf("%s must define light and dark themes", description)
	}
	if normalizedLight, err = normalizeInlineStyleTheme(light); err != nil {
		return nil, nil, fmt.Errorf("invalid light theme of %s: %w", description, err)
	}
	if normalizedDark, err = normalizeInlineStyleTheme(dark); err != nil {
		return nil, nil, fmt.Errorf("invalid dark theme of %s: %w", description, err)
	}
	lightColor, lightBackground := normalizedLight.Color != "", normalizedLight.BackgroundColor != ""
	darkColor, darkBackground := normalizedDark.Color != "", normalizedDark.BackgroundColor != ""
	if !lightColor && !lightBackground {
		return nil, nil, fmt.Errorf("%s must define color or backgroundColor", description)
	}
	if lightColor != darkColor || lightBackground != darkBackground {
		return nil, nil, fmt.Errorf("%s must use the same fields in light and dark themes", description)
	}
	return normalizedLight, normalizedDark, nil
}

func normalizeHiddenBuiltinColorIndexes(indexes []int, field string) (ret []int, err error) {
	ret = make([]int, 0, len(indexes))
	seen := make(map[int]struct{}, len(indexes))

View on GitHub (pinned to 9f775e8a12)