siyuan-note/siyuan · error
duplicate builtin style ID
Error message
duplicate builtin style ID [%s]
What it means
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.
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
Example fix
// before
"styles": [ {"id": "info", ...}, {"id": "info", ...} ]
// after
"styles": [ {"id": "info", "light": {...}, "dark": {...}} ] Defensive patterns
Strategy: validation
Validate before calling
const seen = new Set();
for (const [i, s] of (cfg.builtin?.styles ?? []).entries()) {
const id = s.id?.trim();
if (seen.has(id)) throw new Error(`duplicate builtin style id '${id}' at entry ${i}`);
seen.add(id);
} Type guard
function styleIDsUnique(styles) { return new Set(styles.map(s => s?.id?.trim())).size === styles.length; } Try / catch
if _, err := setInlineStylesData(styles, currentAV); err != nil {
if strings.Contains(err.Error(), "duplicate builtin style ID") { /* drop the duplicate entry and retry */ }
return err
} Prevention
- 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
When it happens
Trigger: setInlineStylesData or loadInlineStyles finds two builtin.styles entries whose trimmed id is the same (e.g. two "info" entries) in inline-styles.json.
Common situations: 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.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- duplicate builtin color index
- builtin color must not be null
- builtin style must not be null
- invalid builtin style ID
- must define color or backgroundColor
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/c821acd5ebc34e92.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:744
return nil, err
}
ret.Colors = append(ret.Colors, &InlineStyleBuiltinColor{Index: color.Index, Light: light, Dark: dark})
}
sort.Slice(ret.Colors, func(i, j int) bool {
return ret.Colors[i].Index < ret.Colors[j].Index
})
styleIDs := make(map[string]struct{}, len(builtin.Styles))
for _, style := range builtin.Styles {
if style == nil {
return nil, errors.New("builtin style must not be null")
}
id := strings.TrimSpace(style.ID)
if _, valid := builtinStyleOrder[id]; !valid {
return nil, fmt.Errorf("invalid builtin style ID [%s]", id)
}
if _, exists := styleIDs[id]; exists {
return nil, fmt.Errorf("duplicate builtin style ID [%s]", id)
}
styleIDs[id] = struct{}{}
light, dark, err := normalizeInlineStyleThemePair(style.Light, style.Dark, "builtin style ["+id+"]")
if err != nil {
return nil, err
}
ret.Styles = append(ret.Styles, &InlineStyleBuiltinStyle{ID: id, Light: light, Dark: dark})
}
sort.Slice(ret.Styles, func(i, j int) bool {
return builtinStyleOrder[ret.Styles[i].ID] < builtinStyleOrder[ret.Styles[j].ID]
})
if builtin.Hidden != nil {
if ret.Hidden.Color, err = normalizeHiddenBuiltinColorIndexes(builtin.Hidden.Color, "color"); err != nil {
return nil, err
}
if ret.Hidden.BackgroundColor, err = normalizeHiddenBuiltinColorIndexes(builtin.Hidden.BackgroundColor,View on GitHub (pinned to 9f775e8a12)