siyuan-note/siyuan · error

invalid dark theme of

Error message

invalid dark theme of %s: %w

What it means

Identical to error 1597 but for the dark theme object: dark.color or dark.backgroundColor failed hex validation, wrapped with the 'invalid dark theme of %s' prefix so the offending entry can be located.

Solutions

  1. Fix the dark theme color to a valid #RRGGBB hex value
  2. Verify the light theme passes too (both are validated)
  3. Normalize letters to lowercase (the normalizer does this, but keep files consistent)
  4. Reload the workspace and toggle to dark mode to confirm rendering

Example fix

// before
"dark": {"backgroundColor": "#1a1a"}
// after
"dark": {"backgroundColor": "#1a1a1a"}
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.dark?.[f];
    if (v && !HEX.test(v)) throw new Error(`builtin color [${entry.index}] dark.${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 dark theme") { /* convert the reported dark color to #RRGGBB and retry */ }
    return err
}

Prevention

When it happens

Trigger: A builtin entry's dark.color or dark.backgroundColor in inline-styles.json is not #RRGGBB (e.g. '#1a1a', 'none', '#12345G').

Common situations: Editing dark-mode colors by hand; a script writing truncated or malformed hex; converting from rgba() values; sync merges producing corrupted values.

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

Appendix: 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 9f775e8a12)