{"record":{"id":"5ff6c24b58d8afff","repo":"siyuan-note/siyuan","slug":"color-s-must-use-rrggbb-format","errorCode":null,"errorMessage":"color [%s] must use #RRGGBB format","messagePattern":"color \\[(.+?)\\] must use #RRGGBB format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":870,"sourceCode":"\nfunc normalizeInlineStyleTheme(theme *InlineStyleTheme) (ret *InlineStyleTheme, err error) {\n\tret = &InlineStyleTheme{}\n\tif ret.Color, err = normalizeInlineStyleColor(theme.Color); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid color: %w\", err)\n\t}\n\tif ret.BackgroundColor, err = normalizeInlineStyleColor(theme.BackgroundColor); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid backgroundColor: %w\", err)\n\t}\n\treturn ret, nil\n}\n\nfunc normalizeInlineStyleColor(color string) (ret string, err error) {\n\tret = strings.ToLower(strings.TrimSpace(color))\n\tif ret == \"\" {\n\t\treturn ret, nil\n\t}\n\tif !inlineStyleColorPattern.MatchString(ret) {\n\t\treturn \"\", fmt.Errorf(\"color [%s] must use #RRGGBB format\", color)\n\t}\n\treturn ret, nil\n}\n\nfunc init() {\n\tav.LoadWorkspacePalette = loadWorkspaceAVPalette\n}\n\nfunc loadWorkspaceAVPalette() (colors []*av.AttributeViewCustomColor, order []string) {\n\twaitForSyncingStorages()\n\tinlineStylesLock.Lock()\n\tdefer inlineStylesLock.Unlock()\n\tif workspaceAVPaletteCache == nil || workspaceAVPaletteCachePath != inlineStylesPath() {\n\t\tstyles, err := loadInlineStyles()\n\t\tif err != nil {\n\t\t\treturn nil, nil\n\t\t}\n\t\tcacheWorkspaceAVPalette(styles.AV)","sourceCodeStart":852,"sourceCodeEnd":888,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L852-L888","documentation":"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.","triggerScenarios":"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.","commonSituations":"Pasting colors from CSS frameworks or design tools; abbreviating hex; accidentally including alpha channels (#RRGGBBAA); localized input methods inserting full-width characters.","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\""],"exampleFix":"// before\ncolor: \"transparent\"\n// after\ncolor: \"\"","handlingStrategy":"validation","validationCode":"function normalizeToHex6(input) {\n  const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(input).trim());\n  if (!m) return \"\";\n  let h = m[1];\n  if (h.length === 3) h = [...h].map(c => c + c).join(\"\");\n  return \"#\" + h.toLowerCase();\n}","typeGuard":"const isHexColor = v => typeof v === \"string\" && /^#[0-9a-fA-F]{6}$/.test(v.trim());","tryCatchPattern":null,"preventionTips":["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"],"tags":["validation","color","format","hex"],"backgroundTag":"invalid-argument-format","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}