{"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":"error_code","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/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L270-L306","documentation":"setInlineStylesData reads the existing inline-styles file (via filelock.ReadFile) to detect no-op writes (byte-equal short-circuit) and to preserve state. Any read error other than os.IsNotExist aborts the update. This means I/O problems — permissions, device errors, lock conflicts — surface wrapped in this message.","triggerScenarios":"storage/inline_styles exists but is unreadable (permissions changed, file owned by another user, read-only mount); filelock contention or underlying FS error; corrupted filesystem returning EIO.","commonSituations":"Running the kernel as a different user after a sudo session; workspace on a network/external drive that went read-only; Windows file locked by backup software (depending on filelock behavior).","solutions":["Check and fix filesystem permissions on the workspace storage directory and the styles file","Confirm the disk/mount is writable (read-only mounts, full disks, disconnected network drives)","Close programs holding the file (backup/AV tools) and retry","As a last resort, back up and remove the unreadable file — the setter will treat it as not-exist and recreate it, losing old palette customizations"],"exampleFix":"# before\n-rw------- root storage/inline_styles  # unreadable by kernel user\n# after\nchown siyuan:siyuan storage/inline_styles && chmod 600 storage/inline_styles","handlingStrategy":"retry","validationCode":"if f, err := os.Open(stylesPath); err != nil && !os.IsNotExist(err) {\n    return fmt.Errorf(\"styles file unreadable before write: %w\", err)\n} else if f != nil { f.Close() }","typeGuard":null,"tryCatchPattern":"_, _, err := model.SetInlineStyles(styles)\nif err != nil && strings.HasPrefix(err.Error(), \"read inline styles failed\") {\n    time.Sleep(200 * time.Millisecond)\n    _, _, err = model.SetInlineStyles(styles) // retry once for transient lock/IO\n}","preventionTips":["Run the kernel under a user with read access to the whole workspace","Avoid external tools (backup/AV) holding locks on workspace storage files","Monitor the workspace volume for read-only transitions or disk errors"],"tags":["go","filesystem","io","file-read"],"backgroundTag":"file-read-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}