{"record":{"id":"233d920b35669b5f","repo":"siyuan-note/siyuan","slug":"inline-styles-must-not-be-null","errorCode":null,"errorMessage":"inline styles must not be null","messagePattern":"inline styles must not be null","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":231,"sourceCode":"\t\t\t})\n\t\t}\n\t\tfilteredHidden := current.Builtin.Hidden.AV[:0]\n\t\tfor _, index := range current.Builtin.Hidden.AV {\n\t\t\tif index != patch.Index {\n\t\t\t\tfilteredHidden = append(filteredHidden, index)\n\t\t\t}\n\t\t}\n\t\tcurrent.Builtin.Hidden.AV = filteredHidden\n\t\tif patch.Hidden {\n\t\t\tcurrent.Builtin.Hidden.AV = append(current.Builtin.Hidden.AV, patch.Index)\n\t\t}\n\t}\n\treturn setInlineStylesData(current, currentAV)\n}\n\nfunc setInlineStylesData(styles *InlineStyles, currentAV *InlineStyleAV) (ret *InlineStyles, changed bool, err error) {\n\tif styles == nil {\n\t\treturn nil, false, errors.New(\"inline styles must not be null\")\n\t}\n\tif styles.Version != InlineStylesVersion {\n\t\treturn nil, false, fmt.Errorf(\"unsupported inline styles version [%d]\", styles.Version)\n\t}\n\tif currentAV == nil {\n\t\tcurrentAV = newEmptyInlineStyleAV()\n\t}\n\n\tnormalizedStyles, err := normalizeInlineStyles(styles.Styles, true)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tnormalizedBuiltin, err := normalizeInlineStyleBuiltin(styles.Builtin)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tnormalizedAV, err := normalizeInlineStyleAV(styles.AV, true)\n\tif err != nil {","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L213-L249","documentation":"setInlineStylesData rejects a nil *InlineStyles pointer before doing any work. The kernel stores workspace inline styles (including attribute-view palettes) as a versioned JSON document, and mutating that document requires a non-nil input struct. Callers that pass nil (e.g. decoding a missing/empty payload into a nil pointer) hit this guard immediately.","triggerScenarios":"Calling SetInlineStyles / SetInlineStylesData with a nil styles argument, or SetWorkspaceAVPalette / replaceWorkspaceAVPalette when the loaded or decoded InlineStyles is nil (e.g. unmarshalling an absent or invalid JSON body leaves the pointer nil).","commonSituations":"An HTTP request body that is empty or fails to decode into *InlineStyles, an API client omitting the styles field entirely, or plugin/binding code constructing the call without initializing the struct.","solutions":["Ensure the request payload contains a valid inline styles JSON object so it decodes into a non-nil *InlineStyles.","If starting from scratch, create an empty styles value (e.g. &model.InlineStyles{Version: model.InlineStylesVersion, Styles: ...}) instead of passing nil.","Add a nil check in the calling code before invoking SetInlineStyles/SetInlineStylesData and return a client-side validation error."],"exampleFix":"// before\nvar styles *model.InlineStyles\nret, changed, err := model.SetInlineStylesData(styles)\n// after\nstyles := &model.InlineStyles{Version: model.InlineStylesVersion}\nret, changed, err := model.SetInlineStylesData(styles)","handlingStrategy":"type-guard","validationCode":"if styles == nil {\n    return errors.New(\"inline styles payload is required\")\n}","typeGuard":"func isValidInlineStyles(s *model.InlineStyles) bool { return s != nil }","tryCatchPattern":null,"preventionTips":["Always initialize InlineStyles with a valid Version and Styles slice before calling the API","Check decode results: an empty request body yields a nil pointer","Wrap API calls in helpers that validate inputs first"],"tags":["null-argument","inline-styles","validation"],"backgroundTag":"null-argument","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"}