siyuan-note/siyuan · error
invalid builtin style ID
Error message
invalid builtin style ID [%s]
What it means
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.
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
Example fix
// before
{"id": "warn", "light": {...}, "dark": {...}}
// after
{"id": "warning", "light": {...}, "dark": {...}} Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = new Set(['error', 'warning', 'info', 'success']);
for (const [i, s] of (cfg.builtin?.styles ?? []).entries()) {
if (!ALLOWED.has(s.id?.trim())) throw new Error(`builtin.styles[${i}].id '${s.id}' not in ${[...ALLOWED]}`);
} Type guard
function isKnownStyleID(id) { return ['error', 'warning', 'info', 'success'].includes(typeof id === 'string' ? id.trim() : ''); } Try / catch
if _, err := setInlineStylesData(styles, currentAV); err != nil {
if strings.Contains(err.Error(), "invalid builtin style ID") { /* fix or move the offending entry */ }
return err
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- builtin color must not be null
- builtin style must not be null
- duplicate builtin color index
- duplicate builtin style ID
- must define color or backgroundColor
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/850e513c09674036.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:741
light, dark, err := normalizeInlineStyleThemePair(color.Light, color.Dark, fmt.Sprintf("builtin color [%d]", color.Index))
if err != nil {
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 {View on GitHub (pinned to 9f775e8a12)