{"record":{"id":"c821acd5ebc34e92","repo":"siyuan-note/siyuan","slug":"duplicate-builtin-style-id-s","errorCode":null,"errorMessage":"duplicate builtin style ID [%s]","messagePattern":"duplicate builtin style ID \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":744,"sourceCode":"\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 {\n\t\t\treturn nil, err\n\t\t}\n\t\tif ret.Hidden.BackgroundColor, err = normalizeHiddenBuiltinColorIndexes(builtin.Hidden.BackgroundColor,","sourceCodeStart":726,"sourceCodeEnd":762,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L726-L762","documentation":"Each builtin style ID may appear at most once in builtin.styles. Duplicates would make ordering and lookup ambiguous (builtinStyleOrder maps each ID to a single position), so normalization rejects the file with this error.","triggerScenarios":"setInlineStylesData or loadInlineStyles finds two builtin.styles entries whose trimmed id is the same (e.g. two \"info\" entries) in inline-styles.json.","commonSituations":"Merge-conflict resolution in inline-styles.json keeping both versions of an entry; copy-paste duplication when tweaking a builtin style; a sync tool re-appending entries.","solutions":["Delete the duplicate entry, keeping the one with the desired light/dark themes","If both are wanted as distinct styles, move one to the user-defined styles section with a new custom ID","Deduplicate the array programmatically before saving","Reload the workspace and verify each builtin style appears exactly once"],"exampleFix":"// before\n\"styles\": [ {\"id\": \"info\", ...}, {\"id\": \"info\", ...} ]\n// after\n\"styles\": [ {\"id\": \"info\", \"light\": {...}, \"dark\": {...}} ]","handlingStrategy":"validation","validationCode":"const seen = new Set();\nfor (const [i, s] of (cfg.builtin?.styles ?? []).entries()) {\n  const id = s.id?.trim();\n  if (seen.has(id)) throw new Error(`duplicate builtin style id '${id}' at entry ${i}`);\n  seen.add(id);\n}","typeGuard":"function styleIDsUnique(styles) { return new Set(styles.map(s => s?.id?.trim())).size === styles.length; }","tryCatchPattern":"if _, err := setInlineStylesData(styles, currentAV); err != nil {\n    if strings.Contains(err.Error(), \"duplicate builtin style ID\") { /* drop the duplicate entry and retry */ }\n    return err\n}","preventionTips":["Keep exactly one entry per builtin style ID","Deduplicate after resolving merge conflicts in inline-styles.json","When tweaking a builtin style, edit in place instead of appending a new entry","Add a pre-save lint that asserts 4 unique IDs"],"tags":["config","validation","duplicate-key","inline-styles"],"backgroundTag":"conflicting-config-options","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"}