{"record":{"id":"daf0cc9c3eeedd2a","repo":"siyuan-note/siyuan","slug":"walk-global-assets-s-failed-w","errorCode":null,"errorMessage":"walk global assets [%s] failed: %w","messagePattern":"walk global assets \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/assets.go","lineNumber":2815,"sourceCode":"\t\t}\n\n\t\tif filelock.IsHidden(assetPath) {\n\t\t\t// 清理资源文件时忽略隐藏文件 Ignore hidden files when cleaning unused assets https://github.com/siyuan-note/siyuan/issues/12172\n\t\t\treturn nil\n\t\t}\n\n\t\trelPath, relErr := assetPathMapKey(dataAssetsAbsPath, assetPath, d.IsDir())\n\t\tif relErr != nil {\n\t\t\treturn relErr\n\t\t}\n\t\tassetsAbsPathMap[relPath] = assetPath\n\t\treturn nil\n\t})\n\tif walkErr != nil {\n\t\tif os.IsNotExist(walkErr) {\n\t\t\treturn\n\t\t}\n\t\treturn nil, fmt.Errorf(\"walk global assets [%s] failed: %w\", dataAssetsAbsPath, walkErr)\n\t}\n\treturn\n}\n\nfunc assetPathMapKey(assetsDirPath, assetPath string, isDir bool) (ret string, err error) {\n\trelPath, err := filepath.Rel(assetsDirPath, assetPath)\n\tif err != nil {\n\t\treturn\n\t}\n\trelPath = filepath.ToSlash(relPath)\n\tif relPath == \".\" || relPath == \"..\" || strings.HasPrefix(relPath, \"../\") || path.IsAbs(relPath) {\n\t\terr = fmt.Errorf(\"asset path [%s] is outside assets directory [%s]\", assetPath, assetsDirPath)\n\t\treturn\n\t}\n\n\tret = path.Join(\"assets\", relPath)\n\tif isDir {\n\t\tret += \"/\"","sourceCodeStart":2797,"sourceCodeEnd":2833,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/assets.go#L2797-L2833","documentation":"The kernel failed while walking the global data/assets directory to build a map of asset paths (used by asset cleanup/refresh operations such as RemoveUnusedAssets). filepath.Walk returned a non-nil, non-not-exist error (e.g. permission denied on a subdirectory or I/O error on an entry), which is wrapped with the assets directory path for context. If the directory simply does not exist the walk is treated as a no-op, so this error means a real filesystem failure occurred during traversal.","triggerScenarios":"Calling asset cleanup paths (e.g. the API that removes unused assets) when a file or subdirectory under data/assets cannot be read: unreadable directory permissions, symlink loops, I/O errors, or a race where a file is removed mid-walk.","commonSituations":"Running the kernel in a container where data/assets was mounted with restrictive permissions; an antivirus or backup tool locking files on Windows; a partially-synced cloud-drive folder producing broken entries under data/assets.","solutions":["Check permissions on data/assets and its children (chmod/chown so the kernel user can read everything).","Run with the message's wrapped cause: the %w suffix names the underlying walk error (e.g. 'permission denied' on a specific path) and fix that path.","Exclude or remove broken entries (dead symlinks, locked files) under data/assets.","If the directory is intentionally absent, no action is needed — a missing data/assets is silently tolerated; only fix cases where it exists but is unreadable."],"exampleFix":"// before (server container): data/assets owned by root, kernel runs as siyuan\n// walk global assets [/siyuan/data/assets] failed: open /siyuan/data/assets/sub: permission denied\n// after: fix ownership/permissions on the host or in the container image\nchown -R siyuan:siyuan /siyuan/data/assets\nchmod -R u+rX /siyuan/data/assets","handlingStrategy":"try-catch","validationCode":"const fs = require('fs');\nfunction assertAssetsReadable(dir) {\n  if (!fs.existsSync(dir)) return; // missing dir is tolerated by the kernel\n  fs.accessSync(dir, fs.constants.R_OK | fs.constants.X_OK);\n  for (const e of fs.readdirSync(dir)) fs.accessSync(path.join(dir, e), fs.constants.R_OK);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.removeUnusedAssets();\n} catch (e) {\n  if (/walk global assets .* failed/.test(e.message)) {\n    console.error(\"Check permissions/locks under data/assets:\", e.cause ?? e.message);\n  }\n}","preventionTips":["Run the kernel under a user that owns or can read data/assets recursively.","Exclude data/assets from tools that lock or scan files (antivirus, backup agents).","Avoid symlinks inside data/assets pointing outside the workspace.","Monitor for unreadable entries after restores or cloud-sync merges."],"tags":["filesystem","assets","walk"],"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"}