{"record":{"id":"2563bd4b149693dd","repo":"siyuan-note/siyuan","slug":"errboxnotfound","errorCode":"ErrBoxNotFound","errorMessage":"notebook not found","messagePattern":"notebook not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/tree.go","lineNumber":210,"sourceCode":"\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\tif err = treenode.CheckSpecJSON(data); nil != err {\n\t\treturn\n\t}\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":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/tree.go#L192-L228","documentation":"ErrBoxNotFound is the sentinel error in kernel/model/tree.go's error var block meaning the notebook (box) ID does not exist in the workspace. Domain functions return it (often via errors wrapping) so API handlers can detect a missing notebook and respond distinctly, e.g. with {unavailableNotebook: true}.","triggerScenarios":"Calling createAttributeViewItemDocs / setCreateAttributeViewItemResult-backed API (/api/av/* with blockID) or createDailyNote with a block or notebook ID whose containing notebook was deleted or renamed outside the kernel's registry.","commonSituations":"Client holds a stale notebook ID after the notebook was removed on disk or deleted in another window; daily-note template points at a removed notebook; attribute-view database rows referencing blocks in a deleted notebook.","solutions":["List current notebooks (/api/notebook/lsNotebooks) and confirm the box ID exists; update the client's references to a valid notebook","Reopen the workspace or rescan notebooks so the registry is refreshed if the notebook exists on disk but is not loaded","Remove or correct the stale daily-note configuration under Settings - Daily Note if it points to a deleted notebook","Handle errors.Is(err, model.ErrBoxNotFound) in the caller and surface 'unavailableNotebook' instead of a raw error"],"exampleFix":"// before\nresult, err := model.CreateAttributeViewItemDocs(avID, blockID, saveMode, itemIDs)\n// after\nif errors.Is(err, model.ErrBoxNotFound) {\n    ret.Code = 1\n    ret.Data = map[string]any{\"unavailableNotebook\": true}\n    return\n}","handlingStrategy":"validation","validationCode":"boxes, _ := listNotebooks()\nexists := false\nfor _, b := range boxes {\n    if b.ID == boxID && !b.Closed { exists = true }\n}\nif !exists { return fmt.Errorf(\"notebook %s does not exist\", boxID) }","typeGuard":null,"tryCatchPattern":"if errors.Is(err, model.ErrBoxNotFound) {\n    ret.Data = map[string]any{\"unavailableNotebook\": true}\n    return\n}","preventionTips":["Refresh notebook lists after any delete/rename instead of caching box IDs","Resolve a block's notebook via its ID before writing database items","Validate daily-note target notebooks in settings"],"tags":["go","notebook","not-found"],"backgroundTag":"entity-not-found","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}