{"record":{"id":"f375c33190848c46","repo":"siyuan-note/siyuan","slug":"read-attribute-view-custom-color-usage-s-failed","errorCode":null,"errorMessage":"read attribute view custom color usage [%s] failed: %w","messagePattern":"read attribute view custom color usage \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":437,"sourceCode":"\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{}{}\n\t\t\tret[avID] = used\n\t\t}\n\t\tfor _, index := range indexes {\n\t\t\tused[index] = struct{}{}\n\t\t}\n\t}\n\treturn ret, nil\n}\n\nfunc isInlineStylesRepoPath(filePath string) bool {\n\treturn filePath == inlineStylesRepoPath","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L419-L455","documentation":"While collecting which custom colors are used by each attribute view, av.ReadAttributeViewCustomColorUsageByPath failed for one .json attribute view file. The kernel wraps the AV ID and underlying error. In strict mode this aborts the whole custom color usage refresh; otherwise it is logged and the file is skipped.","triggerScenarios":"setInlineStylesData iterating a corrupt, unreadable, or malformed .json file under data/storage/av or <notebook>/storage/av when strict=true.","commonSituations":"Partially written or corrupted attribute view JSON from an interrupted sync, permission-restricted av files, hand-edited JSON with invalid structure.","solutions":["Inspect the wrapped cause for the specific av file and validate its JSON structure","Fix permissions on <workspace>/data/**/storage/av/*.json","Restore the corrupt .json attribute view file from backup or sync history, then retry"],"exampleFix":"// before (strict abort)\nreturn nil, fmt.Errorf(\"read attribute view custom color usage [%s] failed: %w\", avID, readErr)\n// after: call with strict=false so bad files are skipped\nusage, err := workspaceAttributeViewCustomColorUsage(false)","handlingStrategy":"try-catch","validationCode":"const raw = fs.readFileSync(avPath, 'utf8');\nJSON.parse(raw); // throws before the API call if the av file is corrupt","typeGuard":"const isAvJson = (s) => { try { const o = JSON.parse(s); return typeof o === 'object' && o !== null; } catch { return false; } };","tryCatchPattern":"try {\n  await fetchPost('/api/attr/setInlineStylesData', payload);\n} catch (e) {\n  if (String(e).includes('read attribute view custom color usage')) {\n    logging.warn(`corrupt attribute view ignored: ${e}`);\n  }\n}","preventionTips":["Do not hand-edit .json files under storage/av","Verify attribute view JSON integrity after interrupted syncs","Keep storage/av files readable by the kernel process"],"tags":["av","json","filesystem","corruption"],"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"}