siyuan-note/siyuan · error

invalid color [ ]

Error message

invalid color [%s]

What it means

validateOptionalBootAppearanceColor accepts an empty string (no color) or a string matching bootAppearanceColorPattern (a color syntax such as #RRGGBB). Any non-empty value that fails the pattern — wrong length, missing '#', invalid hex digits, or free text — aborts loading with this error naming the value.

Solutions

  1. Change the color value to a valid pattern-conforming form (e.g. "#1E90FF")
  2. Remove the field entirely if you do not want to set a color (empty is allowed)
  3. Verify the digit count and that only hexadecimal characters 0-9/A-F are used after the '#'

Example fix

// manifest.json before
"backgroundColor": "white"
// after
"backgroundColor": "#FFFFFF"
Defensive patterns

Strategy: validation

Validate before calling

function isValidColor(c) {
  return c === "" || /^#[0-9A-Fa-f]{6}$/.test(c); // align with bootAppearanceColorPattern
}

Type guard

function isHexColor(v) {
  return typeof v === "string" && /^#[0-9A-Fa-f]{6}$/.test(v);
}

Try / catch

try {
  await loadManifest(pkgPath);
} catch (e) {
  const m = String(e).match(/invalid color \[(.+)\]/);
  if (m) { /* replace m[1] with a valid hex color */ }
}

Prevention

When it happens

Trigger: A boot appearance manifest whose optional color field (e.g. a background or accent color) is set to something like "white", "fff", "#12345", "bg-white", or contains spaces.

Common situations: Authors writing CSS color names instead of hex; omitting the leading '#'; using 4- or 8-digit shorthand the pattern does not accept; pasting values with trailing whitespace.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/boot_appearance.go:735

			continue
		}
		if !seen[normalized] {
			seen[normalized] = true
			frontends = append(frontends, normalized)
		}
	}
	if len(frontends) == 0 && len(manifestFrontends) == 0 && len(pluginFrontends) == 0 {
		frontends = append(frontends, "desktop", "mobile")
	}
	if len(frontends) == 0 {
		return nil, errors.New("no supported frontend")
	}
	return frontends, nil
}

func validateOptionalBootAppearanceColor(color string) error {
	if color != "" && !bootAppearanceColorPattern.MatchString(color) {
		return fmt.Errorf("invalid color [%s]", color)
	}
	return nil
}

func isValidBootAppearanceID(id string) bool {
	return len(id) <= 64 && bootAppearanceIDPattern.MatchString(id)
}

func isSafeBootAppearanceRelativePath(relativePath string) bool {
	if relativePath == "" || len(relativePath) > maxBootAppearancePathLength || strings.Contains(relativePath, "\\") ||
		strings.ContainsAny(relativePath, `<>:"|?*`) || strings.HasPrefix(relativePath, "/") ||
		filepath.IsAbs(relativePath) || filepath.VolumeName(relativePath) != "" {
		return false
	}
	segments := strings.Split(relativePath, "/")
	if len(segments) > maxBootAppearancePathDepth {
		return false
	}

View on GitHub (pinned to 9f775e8a12)