{"record":{"id":"f7773e9c4eb1010d","repo":"siyuan-note/siyuan","slug":"read-inline-styles-failed-w","errorCode":null,"errorMessage":"read inline styles failed: %w","messagePattern":"read inline styles failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":288,"sourceCode":"\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}\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)","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L270-L306","documentation":"Before writing, the kernel reads the existing inline styles file under a file lock to compare content. Any read error other than os.IsNotExist (permission problems, I/O errors, lock corruption) aborts the update, wrapped as this error. A missing file is tolerated and treated as empty.","triggerScenarios":"setInlineStylesData calling filelock.ReadFile on the styles path when the file exists but cannot be read: permission denied, disk I/O error, or the file being locked/corrupted at the OS level.","commonSituations":"Running the kernel as a different user than the file owner; read-only filesystem or full disk; the storage directory synced by another tool holding conflicting locks; SELinux/AppArmor restrictions.","solutions":["Check file permissions on the workspace storage directory and the styles file; fix with chown/chmod so the kernel user can read it.","Verify the disk is writable and healthy (dmesg / disk utility); free space if the disk is full.","Close other processes locking the file (other SiYuan instances, sync tools) and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check readability before calling the API:\n// if _, err := os.Stat(stylesPath); err == nil {\n//     f, err := os.Open(stylesPath); if err != nil { fix permissions first } \n// }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"read inline styles failed\") {\n    // check permissions/disk health, ensure no other process locks the file, then retry\n}","preventionTips":["Run the kernel as the same user that owns the workspace files","Avoid pointing sync/backup tools that hold exclusive locks at the workspace storage directory","Keep the workspace on a healthy, writable local volume"],"tags":["file-io","permissions","inline-styles"],"backgroundTag":"file-read-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"}