{"record":{"id":"333bcb23b511a89b","repo":"siyuan-note/siyuan","slug":"list-attribute-views-failed-w","errorCode":null,"errorMessage":"list attribute views failed: %w","messagePattern":"list attribute views failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":409,"sourceCode":"\t\t\treturn nil\n\t\t}\n\t\tif readErr != nil {\n\t\t\treturn readErr\n\t\t}\n\t\tfor _, entry := range entries {\n\t\t\tif entry.IsDir() || filepath.Ext(entry.Name()) != \".json\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tavID := strings.TrimSuffix(entry.Name(), filepath.Ext(entry.Name()))\n\t\t\tif ast.IsNodeIDPattern(avID) {\n\t\t\t\tpaths = append(paths, filepath.Join(dir, entry.Name()))\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\tif err = appendPaths(filepath.Join(util.DataDir, \"storage\", \"av\")); err != nil {\n\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}","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L391-L427","documentation":"workspaceAttributeViewCustomColorUsage scans storage/av for .av files to build the custom-color usage map. In strict mode (required before removing colors), a failure to list the attribute-view directory aborts with this error instead of proceeding with an incomplete usage map, which would risk deleting colors still in use.","triggerScenarios":"storage/av missing-but-erroring (e.g. it exists as a file, or permission denied on ReadDir); appendPaths returning an error while strict=true is passed from setInlineStylesData's removal check.","commonSituations":"storage/av accidentally replaced by a regular file; permission mismatch after restoring a workspace as root; workspace sync leaving the av directory in a bad state.","solutions":["Verify storage/av exists as a directory and is readable by the kernel user; fix permissions or remove a conflicting regular file","Recreate the storage/av directory (attribute views are re-indexed from .sy/.av data as needed) and retry","Temporarily avoid removing custom colors until the AV listing works, so the strict check is not exercised","Check the wrapped appendPaths/ReadDir error to distinguish permission vs not-a-directory problems"],"exampleFix":"# before\nls -l storage/av   # regular file\n# after\nrm storage/av && mkdir storage/av   # or restore the real av directory","handlingStrategy":"fallback","validationCode":"if fi, err := os.Stat(filepath.Join(dataDir, \"storage\", \"av\")); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"attribute view dir unusable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"usage, err := model.WorkspaceAttributeViewCustomColorUsage(true)\nif err != nil {\n    log.Warnf(\"cannot compute AV color usage, skipping palette pruning: %v\", err)\n    return\n}","preventionTips":["Keep storage/av as a readable directory; do not restore single files over it","Fix workspace ownership after copying/restoring workspaces as root","Defer color-removal operations until AV indexing completes on a freshly synced workspace"],"tags":["go","filesystem","attribute-view","readdir"],"backgroundTag":"directory-not-found","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"}