{"record":{"id":"94b23e3c0ad94ec4","repo":"siyuan-note/siyuan","slug":"0","errorCode":"0","errorMessage":"Query notebook failed","messagePattern":"Query notebook failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/import.go","lineNumber":267,"sourceCode":"\t\t}\n\t\tif removeErr := filelock.Remove(importedBoxDocPath); removeErr != nil {\n\t\t\terr = removeErr\n\t\t\treturn\n\t\t}\n\t}\n\tif autoDetect {\n\t\tif importedMetadataErr != nil {\n\t\t\terr = errors.New(Conf.Language(199))\n\t\t\treturn\n\t\t}\n\t\tcreateNotebook = isSYNotebookExport(hasImportedBoxConf, hasImportedBoxDocMeta)\n\t}\n\tif autoDetect && !createNotebook && boxID == \"\" {\n\t\terr = ErrSYTargetNotebookRequired\n\t\treturn\n\t}\n\tif !createNotebook && nil == Conf.Box(boxID) {\n\t\terr = errors.New(Conf.Language(0))\n\t\treturn\n\t}\n\tif createNotebook {\n\t\tif importedBoxConf != nil && importedBoxConf.Name != \"\" {\n\t\t\tname = importedBoxConf.Name\n\t\t}\n\t\tboxID, err = CreateBox(util.RemoveInvalid(name))\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tcreatedBoxID = boxID\n\t\tdefer func() {\n\t\t\tif err == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttreenode.RemoveBlockTreesByBoxID(boxID)\n\t\t\tsql.DeleteBoxQueue(boxID)\n\t\t\tif removeErr := filelock.Remove(filepath.Join(util.DataDir, boxID)); removeErr != nil {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/import.go#L249-L285","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if !createNotebook && Conf.Box(boxID) == nil {\n    return errors.New(Conf.Language(0))\n}\n// safe to import","typeGuard":"// notebookMounted reports whether boxID is an opened notebook.\nfunc notebookMounted(boxID string) bool {\n    return Conf.Box(boxID) != nil\n}","tryCatchPattern":"err := model.ImportSY(zipPath, boxID, toPath)\nif err != nil && err.Error() == Conf.Language(0) {\n    // refresh the notebook list and let the user re-pick\n}","preventionTips":["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."],"tags":["import","notebook","validation","configuration"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}