{"record":{"id":"94defde80b6107df","repo":"siyuan-note/siyuan","slug":"inline-styles-file-exceeds-the-d-byte-limit","errorCode":null,"errorMessage":"inline styles file exceeds the %d byte limit","messagePattern":"inline styles file exceeds the (.+?) byte limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":282,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t\tfor _, avID := range sortedAttributeViewUsageIDs(customColorUsage) {\n\t\t\tindexes := customColorUsage[avID]\n\t\t\tfor index := range removedIndexes {\n\t\t\t\tif _, used := indexes[index]; used {\n\t\t\t\t\treturn nil, false, fmt.Errorf(\"attribute view custom color [%d] is still in use by attribute view [%s]\",\n\t\t\t\t\t\tindex, avID)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tdata, err := gulu.JSON.MarshalIndentJSON(ret, \"\", \"  \")\n\tif err != nil {\n\t\treturn nil, false, fmt.Errorf(\"marshal inline styles failed: %w\", err)\n\t}\n\tif maxInlineStylesFileSize < len(data) {\n\t\treturn nil, false, fmt.Errorf(\"inline styles file exceeds the %d byte limit\", maxInlineStylesFileSize)\n\t}\n\n\tdataPath := inlineStylesPath()\n\toldData, readErr := filelock.ReadFile(dataPath)\n\tif readErr != nil && !os.IsNotExist(readErr) {\n\t\treturn nil, false, fmt.Errorf(\"read inline styles failed: %w\", readErr)\n\t}\n\tif bytes.Equal(oldData, data) {\n\t\tcacheWorkspaceAVPalette(ret.AV)\n\t\treturn ret, false, nil\n\t}\n\n\tif err = os.MkdirAll(filepath.Dir(dataPath), 0755); err != nil {\n\t\treturn nil, false, fmt.Errorf(\"create inline styles directory failed: %w\", err)\n\t}\n\tif err = filelock.WriteFile(dataPath, data); err != nil {\n\t\treturn nil, false, fmt.Errorf(\"write inline styles failed: %w\", err)\n\t}","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L264-L300","documentation":"The persisted inline styles file has a hard size limit (maxInlineStylesFileSize). After marshalling, if the serialized document exceeds that byte count, the write is refused so the storage file cannot grow unbounded or slow down every load.","triggerScenarios":"SetInlineStyles / SetWorkspaceAVPalette adding custom styles or palette colors until the marshalled JSON exceeds maxInlineStylesFileSize bytes.","commonSituations":"Programmatic bulk import of hundreds of custom colors/styles; a plugin repeatedly appending palette entries without removing unused ones; a long-lived workspace accumulating orphaned style definitions.","solutions":["Prune unused or duplicate custom styles/colors before calling the API and retry.","Batch updates: send one consolidated styles document instead of many incremental additions.","Check the current file size (storage/inline styles path via inlineStylesPath) and reclaim space by removing stale entries."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"data, _ := json.MarshalIndent(styles, \"\", \"  \")\nif len(data) > maxInlineStylesFileSize {\n    // prune unused styles/colors before calling the API\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"byte limit\") {\n    // prune and retry with a smaller document\n}","preventionTips":["Periodically prune unused custom colors and styles","Import palettes in consolidated batches, not one entry per call","Monitor the styles file size as part of workspace maintenance"],"tags":["size-limit","inline-styles","storage"],"backgroundTag":"file-size-limit-exceeded","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"}