siyuan-note/siyuan · error
color [ ] must use #RRGGBB format
Error message
color [%s] must use #RRGGBB format
What it means
normalizeInlineStyleColor trims and lowercases the value, allows empty (meaning unset), and otherwise requires an exact #RRGGBB match against inlineStyleColorPattern. Any non-empty value that does not match — wrong length, missing #, invalid hex digits, or formats like rgb()/hsl()/named colors — is rejected with this message showing the original input.
Solutions
- Provide exactly 6 hex digits preceded by '#', e.g. #1e90ff
- Expand 3-digit hex (#abc -> #aabbcc) and strip alpha channels before saving
- Use empty string to unset the color instead of placeholders like "none" or "transparent"
Example fix
// before color: "transparent" // after color: ""
Defensive patterns
Strategy: validation
Validate before calling
function normalizeToHex6(input) {
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(input).trim());
if (!m) return "";
let h = m[1];
if (h.length === 3) h = [...h].map(c => c + c).join("");
return "#" + h.toLowerCase();
} Type guard
const isHexColor = v => typeof v === "string" && /^#[0-9a-fA-F]{6}$/.test(v.trim()); Prevention
- Run any user-supplied color through a #RRGGBB normalizer before saving
- Ban alpha-channel (#RRGGBBAA) input or strip the alpha bytes
- Show a color picker that emits 6-digit hex only
When it happens
Trigger: Setting an inline style theme color or backgroundColor to "#fff", "ffffff", "#12345", "#1234567", "red", "rgb(1,2,3)", or any non-hex string via the style/theme configuration path.
Common situations: Pasting colors from CSS frameworks or design tools; abbreviating hex; accidentally including alpha channels (#RRGGBBAA); localized input methods inserting full-width characters.
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
- invalid backgroundColor
- invalid color
- invalid background color
- invalid color [ ]
- invalid dark theme of attribute view custom color
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/5ff6c24b58d8afff.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:870
func normalizeInlineStyleTheme(theme *InlineStyleTheme) (ret *InlineStyleTheme, err error) {
ret = &InlineStyleTheme{}
if ret.Color, err = normalizeInlineStyleColor(theme.Color); err != nil {
return nil, fmt.Errorf("invalid color: %w", err)
}
if ret.BackgroundColor, err = normalizeInlineStyleColor(theme.BackgroundColor); err != nil {
return nil, fmt.Errorf("invalid backgroundColor: %w", err)
}
return ret, nil
}
func normalizeInlineStyleColor(color string) (ret string, err error) {
ret = strings.ToLower(strings.TrimSpace(color))
if ret == "" {
return ret, nil
}
if !inlineStyleColorPattern.MatchString(ret) {
return "", fmt.Errorf("color [%s] must use #RRGGBB format", color)
}
return ret, nil
}
func init() {
av.LoadWorkspacePalette = loadWorkspaceAVPalette
}
func loadWorkspaceAVPalette() (colors []*av.AttributeViewCustomColor, order []string) {
waitForSyncingStorages()
inlineStylesLock.Lock()
defer inlineStylesLock.Unlock()
if workspaceAVPaletteCache == nil || workspaceAVPaletteCachePath != inlineStylesPath() {
styles, err := loadInlineStyles()
if err != nil {
return nil, nil
}
cacheWorkspaceAVPalette(styles.AV)View on GitHub (pinned to 9f775e8a12)