siyuan-note/siyuan · error
invalid imported notebook document metadata
Error message
invalid imported notebook document metadata
What it means
When the archive contains .siyuan notebook-document metadata (boxDocMetaName), importSY0 validates it: spec version must equal boxDocMetaSpec and BoxDocID must match a node-ID pattern. Otherwise importedMetadataErr is set to this sentinel error 'invalid imported notebook document metadata', which later surfaces as the generic invalid-archive error (i18n key 199) when autoDetect is on.
Solutions
- Re-export the notebook bundle with a matching (current) SiYuan version
- Fix or remove the .siyuan metadata file in the archive (import will then treat it as a plain document archive)
- Upgrade the SiYuan kernel so it supports the metadata spec used by the archive
Defensive patterns
Strategy: validation
Validate before calling
const meta = JSON.parse(fs.readFileSync(path.join(root, ".siyuan", "boxdoc.json"), "utf8"));
if (meta.spec !== 1 || !/^[0-9]{14}-[a-z0-9]{7}$/.test(meta.boxDocID)) {
throw new Error("boxdoc metadata has unsupported spec or malformed ID");
} Type guard
const isValidBoxDocMeta = (meta) => meta && typeof meta === "object" && typeof meta.BoxDocID === "string" && /^[0-9]{14}-[a-z0-9]{7}$/.test(meta.BoxDocID); Prevention
- Do not hand-edit .siyuan metadata files inside archives
- Import archives with a kernel version that supports their metadata spec
- Re-export rather than copying metadata between archives
When it happens
Trigger: Importing a notebook-bundle .sy.zip whose .siyuan/<boxDocMetaName> file has an unknown spec version, a malformed/missing BoxDocID, or JSON that unmarshals incorrectly.
Common situations: Hand-edited or truncated metadata files inside a re-packed archive; archives produced by newer SiYuan versions with a higher meta spec imported into an older kernel; corrupted sync/backup artifacts.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/bc041553bf67e0f1.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/import.go:485
}
if removeErr := filelock.Remove(importedConfPath); removeErr != nil {
err = removeErr
return
}
}
var importedBoxDocID string
importedBoxDocPath := filepath.Join(unzipRootPath, ".siyuan", boxDocMetaName)
hasImportedBoxDocMeta := filelock.IsExist(importedBoxDocPath)
if hasImportedBoxDocMeta {
metaData, readErr := filelock.ReadFile(importedBoxDocPath)
if readErr == nil {
meta := &boxDocMeta{}
if unmarshalErr := gulu.JSON.UnmarshalJSON(metaData, meta); unmarshalErr != nil {
logging.LogWarnf("parse imported notebook document metadata failed: %s", unmarshalErr)
importedMetadataErr = unmarshalErr
} else if meta.Spec != boxDocMetaSpec || !ast.IsNodeIDPattern(meta.BoxDocID) {
logging.LogWarnf("invalid imported notebook document metadata [spec=%d, id=%s]", meta.Spec, meta.BoxDocID)
importedMetadataErr = errors.New("invalid imported notebook document metadata")
} else {
importedBoxDocID = meta.BoxDocID
}
} else {
logging.LogWarnf("read imported notebook document metadata failed: %s", readErr)
importedMetadataErr = readErr
}
if removeErr := filelock.Remove(importedBoxDocPath); removeErr != nil {
err = removeErr
return
}
}
notebookExport := isSYNotebookExport(hasImportedBoxConf, hasImportedBoxDocMeta)
if len(syPaths) < 1 && !notebookExport {
logging.LogErrorf("invalid .sy.zip without documents or notebook metadata [unzipRootPath=%s]", unzipRootPath)
err = errors.New(Conf.Language(199))
return
}View on GitHub (pinned to 9f775e8a12)