{"record":{"id":"959e59e64e7828cb","repo":"siyuan-note/siyuan","slug":"builtin-color-must-not-be-null","errorCode":null,"errorMessage":"builtin color must not be null","messagePattern":"builtin color must not be null","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":713,"sourceCode":"\t\tif lightColor != darkColor || lightBackground != darkBackground {\n\t\t\treturn nil, fmt.Errorf(\"inline style [%s] must use the same fields in light and dark themes\", id)\n\t\t}\n\n\t\tret = append(ret, &InlineStyle{ID: id, Name: name, Hidden: style.Hidden, Light: light, Dark: dark})\n\t}\n\treturn ret, nil\n}\n\nfunc normalizeInlineStyleBuiltin(builtin *InlineStyleBuiltin) (ret *InlineStyleBuiltin, err error) {\n\tret = newEmptyInlineStyleBuiltin()\n\tif builtin == nil {\n\t\treturn ret, nil\n\t}\n\n\tcolorIndexes := make(map[int]struct{}, len(builtin.Colors))\n\tfor _, color := range builtin.Colors {\n\t\tif color == nil {\n\t\t\treturn nil, errors.New(\"builtin color must not be null\")\n\t\t}\n\t\tif color.Index < minBuiltinColorIndex || neutralAVColorIndex < color.Index {\n\t\t\treturn nil, fmt.Errorf(\"builtin color index [%d] must be between %d and %d\", color.Index,\n\t\t\t\tminBuiltinColorIndex, neutralAVColorIndex)\n\t\t}\n\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","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L695-L731","documentation":"The inline-style builtin configuration contains a null entry in its `colors` array. When normalizing `/storage/inline-styles.json`, every builtin color entry must be a fully-populated object with an index and light/dark themes; a null element cannot be validated, so normalizeInlineStyleBuiltin aborts before any settings are applied.","triggerScenarios":"Calling setInlineStylesData or loadInlineStyles with a builtin JSON payload where the `builtin.colors` array contains a literal `null` element, e.g. `\"colors\": [null]` or `\"colors\": [{...}, null]` in inline-styles.json or an API request body.","commonSituations":"Hand-edited inline-styles.json where an entry was deleted but the comma/placeholder remained; plugin or script that built the colors array with a fixed size and left unfilled slots as null; JSON produced by code that appends nil pointers to a Go slice of *InlineStyleBuiltinColor.","solutions":["Open /storage/inline-styles.json (workspace path data/storage/inline-styles.json) and remove the null element from the builtin.colors array.","If the payload came from an API call or script, fix the serializer to skip empty entries instead of emitting null.","If the file is untrusted or badly broken, delete it so the kernel regenerates defaults, then reconfigure builtin colors through the UI."],"exampleFix":"// before (inline-styles.json)\n\"builtin\": { \"colors\": [ {\"index\": 1, \"light\": {...}, \"dark\": {...}}, null ] }\n// after\n\"builtin\": { \"colors\": [ {\"index\": 1, \"light\": {...}, \"dark\": {...}} ] }","handlingStrategy":"validation","validationCode":"const colors = config?.builtin?.colors ?? [];\nif (colors.some(c => c == null)) {\n  throw new Error(\"builtin.colors contains a null entry\");\n}","typeGuard":"function hasNonNullColors(cfg) {\n  return Array.isArray(cfg?.builtin?.colors) && cfg.builtin.colors.every(c => c != null);\n}","tryCatchPattern":null,"preventionTips":["Never pre-allocate the colors array with placeholder slots; build it by pushing complete entries.","Filter out null/undefined entries before serializing inline-styles.json or calling setInlineStylesData."],"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-14T05:17:10.506Z"}