{"record":{"id":"828274f0fbfbb7e1","repo":"siyuan-note/siyuan","slug":"list-notebook-attribute-views-s-failed-w","errorCode":null,"errorMessage":"list notebook attribute views [%s] failed: %w","messagePattern":"list notebook attribute views \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":426,"sourceCode":"\t\tif strict {\n\t\t\treturn nil, fmt.Errorf(\"list attribute views failed: %w\", err)\n\t\t}\n\t\tlogging.LogWarnf(\"list attribute views for custom color refresh failed: %s\", err)\n\t}\n\tentries, readErr := os.ReadDir(util.DataDir)\n\tif readErr != nil && !os.IsNotExist(readErr) {\n\t\tif strict {\n\t\t\treturn nil, fmt.Errorf(\"list workspace data directory failed: %w\", readErr)\n\t\t}\n\t\tlogging.LogWarnf(\"list workspace data directory for custom color refresh failed: %s\", readErr)\n\t}\n\tfor _, entry := range entries {\n\t\tif !entry.IsDir() || !ast.IsNodeIDPattern(entry.Name()) {\n\t\t\tcontinue\n\t\t}\n\t\tif err = appendPaths(filepath.Join(util.DataDir, entry.Name(), \"storage\", \"av\")); err != nil {\n\t\t\tif strict {\n\t\t\t\treturn nil, fmt.Errorf(\"list notebook attribute views [%s] failed: %w\", entry.Name(), err)\n\t\t\t}\n\t\t\tlogging.LogWarnf(\"list notebook attribute views [%s] for custom color refresh failed: %s\",\n\t\t\t\tentry.Name(), err)\n\t\t}\n\t}\n\tsort.Strings(paths)\n\tfor _, path := range paths {\n\t\tavID, indexes, readErr := av.ReadAttributeViewCustomColorUsageByPath(path)\n\t\tif readErr != nil {\n\t\t\tif strict {\n\t\t\t\treturn nil, fmt.Errorf(\"read attribute view custom color usage [%s] failed: %w\", avID, readErr)\n\t\t\t}\n\t\t\tlogging.LogWarnf(\"read attribute view custom color usage [%s] for refresh failed: %s\", avID, readErr)\n\t\t\tcontinue\n\t\t}\n\t\tused := ret[avID]\n\t\tif used == nil {\n\t\t\tused = map[int]struct{}{}","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L408-L444","documentation":"During a workspace-wide scan of attribute-view custom color usage, the kernel could not list the `storage/av` directory of a notebook (a directory whose name is a valid node ID) under the data directory. This is wrapped from the underlying os.ReadDir failure, which is anything other than the tolerated not-exist case. In strict mode the whole custom-color usage collection aborts with this error; in non-strict mode it is only logged as a warning.","triggerScenarios":"Calling setInlineStylesData (via SetInlineStylesData or SetWorkspaceAVPalette / replaceWorkspaceAVPalette flows) when os.ReadDir on <data>/<notebookID>/storage/av fails with a permission or I/O error for some notebook, while strict=true.","commonSituations":"Notebook directory with restrictive file permissions (e.g. copied as root onto a user workspace), a file named like a notebook ID replacing the directory, disk errors, or sync tools leaving broken directories.","solutions":["Check and fix filesystem permissions on <workspace>/data/<notebookID>/storage (readable + executable for the kernel process)","Verify <data>/<notebookID> is a real directory, not a file or broken symlink","Re-run the operation; if strict mode keeps failing, check the wrapped cause (%w) for the actual OS error"],"exampleFix":"// before\nif err = appendPaths(filepath.Join(util.DataDir, entry.Name(), \"storage\", \"av\")); err != nil {\n    if strict {\n        return nil, fmt.Errorf(\"list notebook attribute views [%s] failed: %w\", entry.Name(), err)\n    }\n// after: pass strict=false or handle the returned error gracefully\nusage, err := workspaceAttributeViewCustomColorUsage(false)\nif err != nil {\n    logging.LogWarnf(\"skip custom color refresh: %s\", err)\n}","handlingStrategy":"try-catch","validationCode":"const nbDir = `${dataDir}/${notebookID}/storage/av`;\ntry { fs.accessSync(nbDir, fs.constants.R_OK | fs.constants.X_OK); } catch (e) { /* fix perms before calling */ }","typeGuard":null,"tryCatchPattern":"try {\n  await fetchPost('/api/attr/setInlineStylesData', payload);\n} catch (e) {\n  if (String(e).includes('list notebook attribute views')) {\n    logging.warn(`skipping AV color refresh for a notebook: ${e.cause ?? e}`);\n  }\n}","preventionTips":["Keep notebook directories owned by the user running the SiYuan kernel","Do not replace notebook directories with files or dangling symlinks","Ensure storage/av subdirectories survive sync tools intact"],"tags":["filesystem","av","workspace","permissions"],"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"}