siyuan-note/siyuan · error
encrypted document root ID does not match filename [%s]
Error message
encrypted document root ID does not match filename [%s]
What it means
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.
Source
Thrown at kernel/model/encrypted_index.go:79
return nil
}
if entry.Type()&fs.ModeSymlink != 0 {
return fmt.Errorf("encrypted document is a symbolic link [%s]", entry.Name())
}
data, err := filelock.ReadFile(filePath)
if err != nil {
return err
}
plain, err := DecryptFile(boxID, entry.Name(), dek, data)
if err != nil {
return err
}
tree, err := loadTreeByData0(plain)
if err != nil {
return err
}
if tree == nil || tree.Root == nil || tree.Root.ID+".sy" != entry.Name() {
return fmt.Errorf("encrypted document root ID does not match filename [%s]", entry.Name())
}
if _, exists := ids[tree.Root.ID]; exists {
return fmt.Errorf("duplicate encrypted document ID [%s]", tree.Root.ID)
}
ids[tree.Root.ID] = struct{}{}
return nil
})
}
View on GitHub (pinned to 8641553a1f)
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.
Example fix
// before data/boxes/<box>/my-note.sy (root ID inside: 20240101120000-abc123) // after mv my-note.sy 20240101120000-abc123.sy
Defensive patterns
Strategy: validation
Validate before calling
base := strings.TrimSuffix(filepath.Base(syPath), ".sy")
if base != rootIDFromTree(syPath) {
return fmt.Errorf("rename %s to %s.sy first", syPath, rootIDFromTree(syPath))
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- cannot rebuild encrypted indexes: %w
- duplicate encrypted document ID [%s]
- encrypted .sy [%s]: base id [%s] != root id [%s]
- invalid encrypted asset plaintext chunk size
- invalid encrypted asset content length
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/a598439d5ecd20c8.
Report an issue: GitHub.