{"record":{"id":"a598439d5ecd20c8","repo":"siyuan-note/siyuan","slug":"encrypted-document-root-id-does-not-match-filename","errorCode":null,"errorMessage":"encrypted document root ID does not match filename [%s]","messagePattern":"encrypted document root ID does not match filename \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/encrypted_index.go","lineNumber":79,"sourceCode":"\t\t\treturn nil\n\t\t}\n\t\tif entry.Type()&fs.ModeSymlink != 0 {\n\t\t\treturn fmt.Errorf(\"encrypted document is a symbolic link [%s]\", entry.Name())\n\t\t}\n\t\tdata, err := filelock.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tplain, err := DecryptFile(boxID, entry.Name(), dek, data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttree, err := loadTreeByData0(plain)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif tree == nil || tree.Root == nil || tree.Root.ID+\".sy\" != entry.Name() {\n\t\t\treturn fmt.Errorf(\"encrypted document root ID does not match filename [%s]\", entry.Name())\n\t\t}\n\t\tif _, exists := ids[tree.Root.ID]; exists {\n\t\t\treturn fmt.Errorf(\"duplicate encrypted document ID [%s]\", tree.Root.ID)\n\t\t}\n\t\tids[tree.Root.ID] = struct{}{}\n\t\treturn nil\n\t})\n}\n","sourceCodeStart":61,"sourceCodeEnd":88,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/encrypted_index.go#L61-L88","documentation":"During encrypted index rebuild, each decrypted document tree must declare the root ID matching its on-disk file name (Root.ID + \".sy\"). If the decrypted root ID differs from the file name, the index cannot safely reference the block, so the rebuild aborts with this error. It is an integrity check binding file identity to document content.","triggerScenarios":"A .sy file in the encrypted box was renamed manually (file name changed but the root ID inside the JSON did not), a document was copied over another file's name, or a partial sync restored mismatched file/content pairs.","commonSituations":"Users renaming .sy files in the file manager; restore scripts copying documents without the matching names; merging workspaces by copying files; corrupted/older file overwriting a newer document's name.","solutions":["Rename the .sy file back to <rootID>.sy using the root ID found inside the decrypted JSON content.","If the file should be a different document, replace its content with the correct document whose root ID matches the file name.","Restore the mismatched document from sync or backup history so file name and root ID agree, then retry the rebuild."],"exampleFix":"// before\ndata/boxes/<box>/my-note.sy   (root ID inside: 20240101120000-abc123)\n// after\nmv my-note.sy 20240101120000-abc123.sy","handlingStrategy":"validation","validationCode":"base := strings.TrimSuffix(filepath.Base(syPath), \".sy\")\nif base != rootIDFromTree(syPath) {\n    return fmt.Errorf(\"rename %s to %s.sy first\", syPath, rootIDFromTree(syPath))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never rename .sy files outside the app","Duplicate documents via the app so new IDs are assigned","Verify file names match root IDs after restores or workspace merges"],"tags":["encryption","index","integrity","naming"],"backgroundTag":"invalid-identifier-format","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"}