siyuan-note/siyuan · error

invalid light theme of %s: %w

Error message

invalid light theme of %s: %w

What it means

The `light` theme of a builtin color/style failed validation inside normalizeInlineStyleTheme; the underlying cause is wrapped after this prefix. Typically the theme's `color` or `backgroundColor` is present but not a valid value — the kernel requires the `#rrggbb` form (inlineStyleColorPattern `^#[0-9a-f]{6}$`). The description names the owning entry, e.g. "invalid light theme of builtin color [5]: ...".

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 8641553a1f)

Solutions

  1. Convert the light theme's color/backgroundColor to 6-digit lowercase hex, e.g. "#e8f0e8".
  2. Expand 3-digit hex (#fff -> #ffffff) and lowercase any uppercase hex digits.
  3. Resolve named colors, rgb()/hsl() values, or CSS variables to concrete hex values before saving.

Example fix

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

Strategy: validation

Validate before calling

const HEX = /^#[0-9a-f]{6}$/;
if (!HEX.test(entry.light.color || "") && !HEX.test(entry.light.backgroundColor || "")) {
  throw new Error("light theme color/backgroundColor must be #rrggbb");
}

Prevention

When it happens

Trigger: setInlineStylesData or loadInlineStyles where a builtin entry's light theme has color/backgroundColor not matching `#rrggbb` (e.g. "red", "#fff", "#FF0000" uppercase, "rgb(255,0,0)", or an empty string paired incorrectly).

Common situations: Copy-pasting CSS color values from the web (named colors, rgb(), 3-digit hex, uppercase hex); pasting a var(--token) reference; trailing whitespace in the value.

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@8641553a1f (2026-09-11). Data as JSON: /api/errors/c309a91cb86c68c7. Report an issue: GitHub.