{"record":{"id":"850e513c09674036","repo":"siyuan-note/siyuan","slug":"invalid-builtin-style-id-s","errorCode":null,"errorMessage":"invalid builtin style ID [%s]","messagePattern":"invalid builtin style ID \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":741,"sourceCode":"\n\t\tlight, dark, err := normalizeInlineStyleThemePair(color.Light, color.Dark, fmt.Sprintf(\"builtin color [%d]\", color.Index))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tret.Colors = append(ret.Colors, &InlineStyleBuiltinColor{Index: color.Index, Light: light, Dark: dark})\n\t}\n\tsort.Slice(ret.Colors, func(i, j int) bool {\n\t\treturn ret.Colors[i].Index < ret.Colors[j].Index\n\t})\n\n\tstyleIDs := make(map[string]struct{}, len(builtin.Styles))\n\tfor _, style := range builtin.Styles {\n\t\tif style == nil {\n\t\t\treturn nil, errors.New(\"builtin style must not be null\")\n\t\t}\n\t\tid := strings.TrimSpace(style.ID)\n\t\tif _, valid := builtinStyleOrder[id]; !valid {\n\t\t\treturn nil, fmt.Errorf(\"invalid builtin style ID [%s]\", id)\n\t\t}\n\t\tif _, exists := styleIDs[id]; exists {\n\t\t\treturn nil, fmt.Errorf(\"duplicate builtin style ID [%s]\", id)\n\t\t}\n\t\tstyleIDs[id] = struct{}{}\n\n\t\tlight, dark, err := normalizeInlineStyleThemePair(style.Light, style.Dark, \"builtin style [\"+id+\"]\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tret.Styles = append(ret.Styles, &InlineStyleBuiltinStyle{ID: id, Light: light, Dark: dark})\n\t}\n\tsort.Slice(ret.Styles, func(i, j int) bool {\n\t\treturn builtinStyleOrder[ret.Styles[i].ID] < builtinStyleOrder[ret.Styles[j].ID]\n\t})\n\n\tif builtin.Hidden != nil {\n\t\tif ret.Hidden.Color, err = normalizeHiddenBuiltinColorIndexes(builtin.Hidden.Color, \"color\"); err != nil {","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L723-L759","documentation":"Builtin style IDs are a closed set: error, warning, info, success (mapped by builtinStyleOrder). Any other ID (including empty or misspelled ones like 'warn' or 'Error') is rejected because builtin styles are fixed semantic decorations, not user-creatable entries.","triggerScenarios":"setInlineStylesData or loadInlineStyles reads inline-styles.json whose builtin.styles contains an id not present in builtinStyleOrder (e.g. \"\", \"warn\", \"danger\", \"Error\" — IDs are case-sensitive and not trimmed before lookup? note the normalizer trims whitespace, so leading/trailing spaces are tolerated but the trimmed value must match exactly).","commonSituations":"Renaming a style id in a hand-edited config; migrating custom styles into the builtin array instead of custom styles; typos; assuming extra IDs like 'highlight' are allowed.","solutions":["Change the id to one of the allowed values: error, warning, info, success","Move truly custom styles out of builtin.styles into the user-defined styles section of inline-styles.json","Check spelling and case — IDs are lowercase and exact","After editing, reload the workspace and confirm the four builtin styles still render"],"exampleFix":"// before\n{\"id\": \"warn\", \"light\": {...}, \"dark\": {...}}\n// after\n{\"id\": \"warning\", \"light\": {...}, \"dark\": {...}}","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['error', 'warning', 'info', 'success']);\nfor (const [i, s] of (cfg.builtin?.styles ?? []).entries()) {\n  if (!ALLOWED.has(s.id?.trim())) throw new Error(`builtin.styles[${i}].id '${s.id}' not in ${[...ALLOWED]}`);\n}","typeGuard":"function isKnownStyleID(id) { return ['error', 'warning', 'info', 'success'].includes(typeof id === 'string' ? id.trim() : ''); }","tryCatchPattern":"if _, err := setInlineStylesData(styles, currentAV); err != nil {\n    if strings.Contains(err.Error(), \"invalid builtin style ID\") { /* fix or move the offending entry */ }\n    return err\n}","preventionTips":["Treat builtin style IDs as an enum: error | warning | info | success, lowercase, exact","Put custom styles in the user-defined section, never in builtin.styles","Lint the config against the fixed ID set before saving","Do not rename builtin IDs when migrating configs between workspaces"],"tags":["config","validation","invalid-enum-value","inline-styles"],"backgroundTag":"invalid-enum-value","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"}