siyuan-note/siyuan · error
0
0
Error message
Query notebook failed
What it means
Returned by importSY (import.go:267) as Conf.Language(0) = "Query notebook failed" when the import is not creating a notebook (createNotebook==false) but Conf.Box(boxID) returns nil, meaning the supplied target notebook ID does not correspond to any mounted notebook. The code message is generic ("Query notebook failed") but the root cause is a missing or wrong notebook ID.
Source
Thrown at kernel/model/import.go:267
}
if removeErr := filelock.Remove(importedBoxDocPath); removeErr != nil {
err = removeErr
return
}
}
if autoDetect {
if importedMetadataErr != nil {
err = errors.New(Conf.Language(199))
return
}
createNotebook = isSYNotebookExport(hasImportedBoxConf, hasImportedBoxDocMeta)
}
if autoDetect && !createNotebook && boxID == "" {
err = ErrSYTargetNotebookRequired
return
}
if !createNotebook && nil == Conf.Box(boxID) {
err = errors.New(Conf.Language(0))
return
}
if createNotebook {
if importedBoxConf != nil && importedBoxConf.Name != "" {
name = importedBoxConf.Name
}
boxID, err = CreateBox(util.RemoveInvalid(name))
if err != nil {
return "", err
}
createdBoxID = boxID
defer func() {
if err == nil {
return
}
treenode.RemoveBlockTreesByBoxID(boxID)
sql.DeleteBoxQueue(boxID)
if removeErr := filelock.Remove(filepath.Join(util.DataDir, boxID)); removeErr != nil {View on GitHub (pinned to 251596fc0d)
Solutions
- Pass a notebook ID obtained from the notebook list API (Conf.Box / /api/notebook/lsNotebooks), not a typed string.
- Ensure the target notebook is opened (mounted) before importing; closed notebooks are invisible to Conf.Box.
- If the notebook was deleted, create a new one or import as a notebook via importSYNotebook/importSYAuto.
Defensive patterns
Strategy: validation
Validate before calling
if !createNotebook && Conf.Box(boxID) == nil {
return errors.New(Conf.Language(0))
}
// safe to import Type guard
// notebookMounted reports whether boxID is an opened notebook.
func notebookMounted(boxID string) bool {
return Conf.Box(boxID) != nil
} Try / catch
err := model.ImportSY(zipPath, boxID, toPath)
if err != nil && err.Error() == Conf.Language(0) {
// refresh the notebook list and let the user re-pick
} Prevention
- Source the notebook ID from the notebook list API, never from typed text.
- Ensure the target notebook is opened (mounted) before importing.
- Re-fetch the notebook list when the picker is opened to avoid stale IDs.
When it happens
Trigger: POST /api/import/importSY or continueImportSY with a "notebook" field that is empty, misspelled, refers to a closed/deleted notebook, or to a notebook that exists on another workspace.
Common situations: User typed the notebook ID manually; notebook was closed/removed between choosing it in the dialog and submitting; wrong workspace selected; clipboard contained an old notebook ID.
Related errors
- --notebook is required
- Please specify the daily note save path in the Notebook Sett
- invalid import token
- no file found
- import path is not sub path of import dir
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/94b23e3c0ad94ec4.
Report an issue: GitHub.