siyuan-note/siyuan · error

invalid dark theme of %s: %w

Error message

invalid dark theme of %s: %w

What it means

The `dark` theme of a builtin color/style failed validation inside normalizeInlineStyleTheme, with the underlying cause wrapped after this prefix. As with the light theme, color/backgroundColor values must be valid `#rrggbb` hex strings. The description identifies the owning builtin color or style entry.

Source

Thrown at kernel/model/inline_style.go:799

	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))
	maxIndex := maxBuiltinColorIndex
	if field == "av" {
		maxIndex = neutralAVColorIndex

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Rewrite the dark theme's color/backgroundColor as 6-digit lowercase hex (e.g. "#1e1e1e").
  2. Normalize all theme values through the same formatter so light and dark both pass the #rrggbb check.
  3. Validate with a regex ^#[0-9a-f]{6}$ in your tooling before calling setInlineStylesData.

Example fix

// before
"dark": {"backgroundColor": "rgb(30,30,30)"}
// after
"dark": {"backgroundColor": "#1e1e1e"}
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: setInlineStylesData or loadInlineStyles where a builtin entry's dark theme has an invalid color/backgroundColor value (named color, shorthand hex, uppercase hex, rgb() string, or otherwise non-#rrggbb).

Common situations: Authoring dark themes by hand from CSS snippets; theme export from another tool using different color notation; mixed-case hex from a color picker that emits uppercase.

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/3c5e84ef79e0bfe9. Report an issue: GitHub.