{"record":{"id":"aa1a49227e5cce3f","repo":"siyuan-note/siyuan","slug":"errboxunindexed","errorCode":"ErrBoxUnindexed","errorMessage":"notebook unindexed","messagePattern":"notebook unindexed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/tree.go","lineNumber":215,"sourceCode":"\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}\n\n\tbt := treenode.GetBlockTreeInBox(id, boxID)\n\tif nil == bt && \"\" == boxID {\n\t\t// boxID 未知时（如通用打开入口），遍历所有已打开的加密笔记本查找\n\t\tfor _, encBoxID := range treenode.GetOpenedEncryptedBoxIDs() {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/tree.go#L197-L233","documentation":"ErrBoxUnindexed is the sentinel error meaning the notebook has not been indexed yet (or is closed/unindexed during tree loading). getBlockInfo and indexTreeInFilesystem return it; the kernel pushes a user-facing message (Language(197)) itself, so API handlers deliberately return an empty message to avoid double notifications.","triggerScenarios":"Requesting block info from a notebook that was never indexed (freshly created or restored notebook); indexTreeInFilesystem encountering a closed box during tree load and returning ErrBoxUnindexed after pushing the 'notebook closed, please open' message.","commonSituations":"Opening a workspace restored from backup where indexes are not yet built; querying a newly imported notebook before its first index pass; automation hitting an unindexed/closed notebook.","solutions":["Wait for indexing of the notebook to complete, or run Rebuild Index on the notebook (right-click notebook - Rebuild Index)","Open the closed notebook first — the kernel pushes a message prompting this, then retry the operation","In API handlers, match errors.Is(err, model.ErrBoxUnindexed) and return an empty message since the user was already notified"],"exampleFix":"// before\nret.Msg = err.Error()\n// after\nif errors.Is(err, model.ErrBoxUnindexed) {\n    ret.Code = -1\n    ret.Msg = \"\" // kernel already pushed a prompt\n}","handlingStrategy":"retry","validationCode":"if isNotebookClosedOrUnindexed(boxID) {\n    return fmt.Errorf(\"notebook %s is not indexed; open or rebuild index first\", boxID)\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, model.ErrBoxUnindexed) {\n    // kernel already notified the user; no extra message needed\n    return\n}","preventionTips":["Open notebooks before querying them in automations","Run Rebuild Index on restored/imported notebooks","Wait for initial indexing after workspace restore"],"tags":["go","notebook","indexing","unindexed"],"backgroundTag":"operation-not-supported","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}