{"record":{"id":"02bf6277fc6848f2","repo":"siyuan-note/siyuan","slug":"builtin-style-must-not-be-null","errorCode":null,"errorMessage":"builtin style must not be null","messagePattern":"builtin style must not be null","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":737,"sourceCode":"\t\tif _, exists := colorIndexes[color.Index]; exists {\n\t\t\treturn nil, fmt.Errorf(\"duplicate builtin color index [%d]\", color.Index)\n\t\t}\n\t\tcolorIndexes[color.Index] = struct{}{}\n\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]","sourceCodeStart":719,"sourceCodeEnd":755,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L719-L755","documentation":"A null entry was found in the builtin `styles` array. Builtin styles are the fixed set (error, warning, info, success); each entry must be a non-null object so its ID and light/dark themes can be validated. A null element cannot be normalized and aborts the whole builtin configuration load.","triggerScenarios":"setInlineStylesData or loadInlineStyles with builtin.styles containing a literal `null`, e.g. `\"styles\": [{\"id\": \"error\", ...}, null]`.","commonSituations":"Hand-edited inline-styles.json with a leftover placeholder; Go/JS code that pre-allocates a 4-element array and fills only some slots; JSON round-trip that serialized missing entries as null.","solutions":["Remove the null element from the builtin.styles array in /storage/inline-styles.json or the API payload.","Fix the generating code to omit empty entries rather than emitting null.","If the file is corrupted beyond repair, delete it so defaults are regenerated and reconfigure via the settings UI."],"exampleFix":"// before\n\"styles\": [ {\"id\": \"error\", ...}, null ]\n// after\n\"styles\": [ {\"id\": \"error\", ...} ]","handlingStrategy":"validation","validationCode":"const styles = config?.builtin?.styles ?? [];\nif (styles.some(s => s == null)) {\n  throw new Error(\"builtin.styles contains a null entry\");\n}","typeGuard":"function hasNonNullStyles(cfg) {\n  return Array.isArray(cfg?.builtin?.styles) && cfg.builtin.styles.every(s => s != null);\n}","tryCatchPattern":null,"preventionTips":["Omit absent style entries instead of writing null placeholders into the styles array.","Validate the full JSON with a schema (required object items) before persisting inline-styles.json."],"tags":["go","configuration","inline-styles","null-value"],"backgroundTag":"null-argument","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}