{"record":{"id":"039f6d2c6e36379d","repo":"siyuan-note/siyuan","slug":"write-inline-styles-failed-w","errorCode":null,"errorMessage":"write inline styles failed: %w","messagePattern":"write inline styles failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":299,"sourceCode":"\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}\n\tcacheWorkspaceAVPalette(ret.AV)\n\tIncSync()\n\tfor _, avID := range sortedAttributeViewUsageIDs(customColorUsage) {\n\t\tindexes := customColorUsage[avID]\n\t\tif intersectsCustomColorIndexes(indexes, changedCustomColorIndexes) {\n\t\t\tpushReloadAttrView(avID)\n\t\t}\n\t}\n\treturn ret, true, nil\n}\n\nfunc inlineStylesPath() string {\n\treturn filepath.Join(util.DataDir, \"storage\", \"inline-styles.json\")\n}\n\nfunc cacheWorkspaceAVPalette(palette *InlineStyleAV) {\n\tworkspaceAVPaletteCache, _ = normalizeInlineStyleAV(palette, false)","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L281-L317","documentation":"After the directory exists, the styles JSON is persisted with filelock.WriteFile. Any write failure (disk full, permission denied, I/O error, lock contention) aborts the update, wrapped as this error, leaving the old file intact.","triggerScenarios":"setInlineStylesData calling filelock.WriteFile on the styles path when the filesystem rejects the write — disk full, no write permission, file held by another process, or underlying I/O failure.","commonSituations":"Full disk during a large palette import; workspace folder owned by another user; backup/sync tools locking the storage file; failing disk sectors.","solutions":["Free disk space and verify the volume is writable, then retry the operation.","Fix permissions on the storage file/directory for the kernel process user (chmod/chown).","Stop competing processes (second SiYuan instance, sync/backup clients) holding the file lock and retry."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight: disk free space and write permission on the storage directory\n// unix.Access(dirPath, unix.W_OK)","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"write inline styles failed\") {\n    // free disk space / fix locks, wait briefly, then retry with backoff\n}","preventionTips":["Monitor disk free space on the workspace volume","Stop competing SiYuan instances and file-locking sync tools before large palette imports","Verify write permissions after OS or user changes"],"tags":["file-io","write-failure","inline-styles"],"backgroundTag":"file-write-failed","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"}