{"record":{"id":"37fc636858764de5","repo":"siyuan-note/siyuan","slug":"invalid-document-file-s","errorCode":null,"errorMessage":"invalid document file [%s]","messagePattern":"invalid document file \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/filesys/tree.go","lineNumber":321,"sourceCode":"\t\tif \"\" == title {\n\t\t\ttitle = \"Untitled\"\n\t\t}\n\t\thPathBuilder.WriteString(title)\n\t\thPathBuilder.WriteString(\"/\")\n\t}\n\thPathBuilder.WriteString(ret.Root.IALAttr(\"title\"))\n\tret.HPath = hPathBuilder.String()\n\tret.Hash = treenode.NodeHash(ret.Root, ret, luteEngine)\n\treturn\n}\n\nfunc checkTreeFile(absPath string) error {\n\tinfo, err := os.Stat(absPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !info.Mode().IsRegular() {\n\t\treturn fmt.Errorf(\"invalid document file [%s]\", absPath)\n\t}\n\treturn nil\n}\n\n// readParentDocIAL 区分父文档缺失与读取、认证、解析失败，只有缺失才允许补树。\nfunc readParentDocIAL(absPath string) (map[string]string, error) {\n\treturn readDocIAL(absPath, false)\n}\n\nfunc readDocIAL(absPath string, strict bool) (map[string]string, error) {\n\tboxID := docIALBoxID(absPath)\n\tdek, _, release, err := acquireCryptoLease(boxID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer release()\n\tdata, err := filelock.ReadFile(absPath)\n\tif err != nil {","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/filesys/tree.go#L303-L339","documentation":"checkTreeFile stats the absolute .sy path and requires it to be a regular file. os.Stat errors are returned as-is; when the file exists but is not a regular file (directory, symlink to non-file, device, socket), this error is returned. It prevents tree loading from treating non-regular filesystem entries as documents.","triggerScenarios":"LoadTreeWithFix or LoadTreeByData resolving to a path that is a directory named like a document (e.g. \".../doc.sy/\" existing as a folder), a FIFO/socket, or a broken special file.","commonSituations":"A document path colliding with a directory of the same name; sync or third-party tools leaving directories where .sy files belong; odd filesystem entries created by mounting or backups.","solutions":["Inspect the path: if it is a directory, rename or remove it and restore the .sy file.","Restore the missing .sy document from sync, history, or backup.","Confirm the path passed to the loader points at the .sy file itself, not a parent directory."],"exampleFix":"// before\nLoadTreeWithFix(boxID, \"/doc.sy\", lute) // data/<box>/doc.sy is a directory\n// after\n// remove/rename the directory and restore the regular file doc.sy, then retry","handlingStrategy":"validation","validationCode":"const st = require(\"fs\").statSync(absPath);\nif (!st.isFile()) throw new Error(absPath + \" is not a regular file\");","typeGuard":null,"tryCatchPattern":"if err := os.Stat(absPath); err != nil || !info.Mode().IsRegular() {\n    // restore the .sy file before loading\n}","preventionTips":["Verify the target exists as a regular file before loading a tree.","Watch for directories or symlinks masquerading as .sy documents.","Restore suspicious entries from backup/sync instead of forcing loads."],"tags":["filesystem","validation","document-tree"],"backgroundTag":"path-is-not-a-directory","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"}