{"record":{"id":"c36796dd55195000","repo":"siyuan-note/siyuan","slug":"opened-notebook-s-not-found","errorCode":null,"errorMessage":"opened notebook [%s] not found","messagePattern":"opened notebook \\[(.+?)\\] not found","errorType":"http","errorClass":null,"httpStatus":200,"severity":"error","filePath":"kernel/api/import.go","lineNumber":219,"sourceCode":"\t\tret.Msg = \"opened notebook [\" + createdBoxID + \"] not found\"\n\t\treturn\n\t}\n\tret.Data = map[string]any{\"type\": \"notebook\", \"notebook\": box}\n\tevent := util.NewCmdResult(\"createnotebook\", 0, util.PushModeBroadcast)\n\tevent.Data = map[string]any{\"box\": box, \"existed\": existed}\n\tutil.PushEvent(event)\n}\n\nfunc mountImportedNotebooks(ids []string) (ret []*model.Box, err error) {\n\tfor _, id := range ids {\n\t\tvar existed bool\n\t\texisted, err = model.Mount(id)\n\t\tif nil != err {\n\t\t\treturn\n\t\t}\n\t\tbox := model.Conf.Box(id)\n\t\tif nil == box {\n\t\t\treturn nil, fmt.Errorf(\"opened notebook [%s] not found\", id)\n\t\t}\n\t\tret = append(ret, box)\n\t\tevent := util.NewCmdResult(\"createnotebook\", 0, util.PushModeBroadcast)\n\t\tevent.Data = map[string]any{\"box\": box, \"existed\": existed}\n\t\tutil.PushEvent(event)\n\t}\n\treturn\n}\n\nfunc continueImportSY(c *gin.Context) {\n\tret := gulu.Ret.NewResult()\n\tdefer c.JSON(http.StatusOK, ret)\n\n\targ, ok := util.JsonArg(c, ret)\n\tif !ok {\n\t\treturn\n\t}\n\tvar token, notebook string","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/api/import.go#L201-L237","documentation":"Thrown by mountImportedNotebooks (kernel/api/import.go) during .sy import flows. model.Mount(id) reported success (mounting the imported notebook), but model.Conf.Box(id) then returned nil — the notebook exists on disk yet has no entry in the workspace's notebook configuration. The import aborts rather than returning a half-tracked box.","triggerScenarios":"Import .sy/.sy.zip flow where the notebook's conf entry is missing or removed concurrently (user closes/removes the notebook in another tab mid-import); conf.json (notebook list) write lost or raced by another operation; importing into a workspace whose configuration file was externally modified or restored mid-run.","commonSituations":"User reorganizes notebooks while a large import runs; sync engine rewrites conf concurrently; workspace restored from backup during import; two imports or an import plus create-notebook racing on conf writes.","solutions":["Retry the import after confirming the notebook's state via /api/notebook/lsNotebooks; if it is mounted but untracked, remove and re-import it","Avoid mutating (closing/removing/reordering) notebooks while an import is in progress","If it recurs consistently, inspect the workspace conf for a stale/partial entry and let the kernel rebuild it on restart, then import again","Import into a fresh notebook id instead of one that other operations are touching"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const nb = await fetchGet('/api/notebook/lsNotebooks');\nconst known = nb.data.notebooks.some(n => n.id === importNotebookId);\nif (!known) { /* clean state: safe to import */ }\n// avoid running imports while notebook open/close/remove operations are active","typeGuard":"const isTrackedNotebook = (boxId: string, notebooks: { id: string }[]): boolean =>\n  notebooks.some(n => n.id === boxId);","tryCatchPattern":"try {\n  await runSyImport(zipPath);\n} catch (e) {\n  if (/opened notebook \\[.*\\] not found/.test(e.message)) {\n    await delay(1000);\n    const nb = await fetchGet('/api/notebook/lsNotebooks'); // state settles, then retry once\n    if (isTrackedNotebook(id, nb.data.notebooks)) await runSyImport(zipPath);\n  }\n}","preventionTips":["Freeze notebook mutations (close/remove/rename) for the duration of an import","Serialize imports against notebook-creating operations","On failure, reconcile via lsNotebooks before assuming data loss"],"tags":["import","notebook","config","race-condition","siyuan"],"backgroundTag":"notebook-config-missing","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}