{"record":{"id":"ce27516e5074886c","repo":"siyuan-note/siyuan","slug":"inline-styles-count-exceeds-the-d-item-limit","errorCode":null,"errorMessage":"inline styles count exceeds the %d item limit","messagePattern":"inline styles count exceeds the (.+?) item limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":645,"sourceCode":"\thidden := map[int]struct{}{}\n\tfor _, index := range styles.Builtin.Hidden.AV {\n\t\thidden[index] = struct{}{}\n\t}\n\tret := make([]int, 0, neutralAVColorIndex)\n\tfor index := minBuiltinColorIndex; index <= neutralAVColorIndex; index++ {\n\t\tif _, ok := hidden[index]; !ok {\n\t\t\tret = append(ret, index)\n\t\t}\n\t}\n\tif len(ret) == 0 {\n\t\treturn []int{neutralAVColorIndex}\n\t}\n\treturn ret\n}\n\nfunc normalizeInlineStyles(styles []*InlineStyle, generateIDs bool) (ret []*InlineStyle, err error) {\n\tif maxInlineStyles < len(styles) {\n\t\treturn nil, fmt.Errorf(\"inline styles count exceeds the %d item limit\", maxInlineStyles)\n\t}\n\tret = make([]*InlineStyle, 0, len(styles))\n\tids := make(map[string]struct{}, len(styles))\n\tfor _, style := range styles {\n\t\tif style == nil {\n\t\t\treturn nil, errors.New(\"inline style must not be null\")\n\t\t}\n\n\t\tid := strings.TrimSpace(style.ID)\n\t\tif id == \"\" && generateIDs {\n\t\t\tfor {\n\t\t\t\tid = ast.NewNodeID()\n\t\t\t\tif _, exists := ids[id]; !exists {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif !ast.IsNodeIDPattern(id) {","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L627-L663","documentation":"normalizeInlineStyles enforces maxInlineStyles, the maximum number of custom inline styles allowed. When the input slice exceeds this count, normalization aborts with this error; it is reached both when loading an oversized file and when saving (setInlineStylesData) a style list that is too large.","triggerScenarios":"Calling SetInlineStyles/SetInlineStylesData with more styles than maxInlineStyles, or loading an inline-styles file whose styles array already exceeds the cap.","commonSituations":"Importing a large style collection from another workspace or export file, plugins/scripts bulk-adding styles in a loop, or repeated sync merges duplicating style entries until the cap is hit.","solutions":["Prune the style list below maxInlineStyles before saving (remove unused/duplicate styles in the app UI)","Deduplicate entries with identical style payloads; sync merges often create exact duplicates","Split usage across built-in styles instead of creating a custom style per variant","If the limit is genuinely too small for the use case, raise maxInlineStyles in code (developer change)"],"exampleFix":"// before: saving an oversized list fails\nstyles := loadAllImportedStyles() // len > maxInlineStyles\n_, err := setInlineStylesData(styles)\n// after: cap before saving\nif len(styles) > maxInlineStyles {\n    styles = styles[:maxInlineStyles]\n}\n_, err := setInlineStylesData(styles)","handlingStrategy":"validation","validationCode":"function withinStyleLimit(styles, max) {\n  return Array.isArray(styles) && styles.length <= max;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap imported style lists to the limit before saving","Deduplicate identical styles created by repeated sync merges","Prefer built-in styles over creating a custom style for every color variant"],"tags":["limit","validation","inline-styles"],"backgroundTag":"value-out-of-range","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"}