{"record":{"id":"d446a4e189ad465d","repo":"siyuan-note/siyuan","slug":"notebook-not-found","errorCode":null,"errorMessage":"notebook not found","messagePattern":"notebook not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/tree.go","lineNumber":202,"sourceCode":"\t\t}\n\t\t// 从绝对路径推导 box 内相对路径作为 AAD\n\t\trelPath := filepath.ToSlash(strings.TrimPrefix(localPath, filepath.Join(util.DataDir, boxID)+string(os.PathSeparator)))\n\t\tif data, err = DecryptFile(boxID, relPath, dek, data); err != nil {\n\t\t\tlogging.LogErrorf(\"decrypt tree [path=%s] failed: %s\", localPath, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tret, err = dataparser.ParseJSONWithoutFix(data, luteEngine.ParseOptions)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"parse json to tree [%s] failed: %s\", localPath, err)\n\t\treturn\n\t}\n\treturn\n}\n\nvar (\n\tErrBoxNotFound   = errors.New(\"notebook not found\")\n\tErrBoxClosed     = errors.New(\"notebook closed\")\n\tErrBlockNotFound = errors.New(\"block not found\")\n\tErrTreeNotFound  = errors.New(\"tree not found\")\n\tErrIndexing      = errors.New(\"indexing\")\n\tErrBoxUnindexed  = errors.New(\"notebook unindexed\")\n\tErrInvalidID     = errors.New(\"invalid id\")\n)\n\nfunc LoadTreeByBlockIDWithReindex(id string) (ret *parse.Tree, err error) {\n\treturn LoadTreeByBlockIDWithReindexInBox(id, \"\")\n}\n\n// LoadTreeByBlockIDWithReindexInBox 与 LoadTreeByBlockIDWithReindex 一致，但按 boxID 路由 blocktree 查询。\nfunc LoadTreeByBlockIDWithReindexInBox(id, boxID string) (ret *parse.Tree, err error) {\n\tif \"\" == id {\n\t\tlogging.LogWarnf(\"block id is empty\")\n\t\treturn nil, ErrTreeNotFound\n\t}","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/tree.go#L184-L220","documentation":"Sentinel error model.ErrBoxNotFound (kernel/model/tree.go:202). It means the notebook (box) ID is not among the configured notebooks - Conf.GetBox(boxID) returned nil (kernel/model/mount.go:57). It is returned by many file/document operations (file.go, transaction.go, box_doc.go, attribute_view_new_item.go) whenever a boxID parameter cannot be resolved.","triggerScenarios":"API calls carrying a boxID that no longer exists in conf: the notebook was deleted or recreated with a new ID, the ID comes from a different workspace, or it is simply mistyped. Examples: /api/filetree/* ops with a stale box id, transactions targeting an unresolvable box (transaction.go:2417).","commonSituations":"Plugins caching box IDs across workspace switches or after notebook recreation; scripts exported from another machine; nightly jobs running against the wrong workspace.","solutions":["List current notebooks via /api/notebook/lsNotebooks and use one of the returned ids","If the notebook should exist, check you are in the right workspace and reopen or recreate the notebook","Match with errors.Is(err, model.ErrBoxNotFound) and refresh cached IDs instead of retrying blindly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check the notebook exists in this workspace:\n// GET /api/notebook/lsNotebooks -> notebooks[].id\n// In Go: if nil == Conf.GetBox(boxID) { /* refresh ids, abort */ }","typeGuard":"func isBoxNotFound(err error) bool {\n\treturn errors.Is(err, model.ErrBoxNotFound)\n}","tryCatchPattern":"if err := someFileOp(boxID, ...); err != nil {\n\tif errors.Is(err, model.ErrBoxNotFound) {\n\t\t// notebook id is stale: re-list notebooks and refresh cached ids\n\t} else {\n\t\t// propagate\n\t}\n}","preventionTips":["Never cache notebook IDs across workspace switches or notebook recreation","Re-resolve box IDs from /api/notebook/lsNotebooks at the start of each batch job","Treat ErrBoxNotFound as a cache-invalidation signal, not a transient retry candidate"],"tags":["notebook","sentinel-error","not-found","kernel-api"],"backgroundTag":"notebook-not-found","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}