siyuan-note/siyuan · warning
ErrBoxUnindexed
ErrBoxUnindexed
Error message
notebook unindexed
What it means
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.
Source
Thrown at kernel/model/tree.go:215
if err = treenode.CheckSpecJSON(data); nil != err {
return
}
ret, err = dataparser.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
if err != nil {
logging.LogErrorf("parse json to tree [%s] failed: %s", localPath, err)
return
}
return
}
var (
ErrBoxNotFound = errors.New("notebook not found")
ErrBoxClosed = errors.New("notebook closed")
ErrBlockNotFound = errors.New("block not found")
ErrTreeNotFound = errors.New("tree not found")
ErrIndexing = errors.New("indexing")
ErrBoxUnindexed = errors.New("notebook unindexed")
ErrInvalidID = errors.New("invalid id")
)
func LoadTreeByBlockIDWithReindex(id string) (ret *parse.Tree, err error) {
return LoadTreeByBlockIDWithReindexInBox(id, "")
}
// LoadTreeByBlockIDWithReindexInBox 与 LoadTreeByBlockIDWithReindex 一致,但按 boxID 路由 blocktree 查询。
func LoadTreeByBlockIDWithReindexInBox(id, boxID string) (ret *parse.Tree, err error) {
if "" == id {
logging.LogWarnf("block id is empty")
return nil, ErrTreeNotFound
}
bt := treenode.GetBlockTreeInBox(id, boxID)
if nil == bt && "" == boxID {
// boxID 未知时(如通用打开入口),遍历所有已打开的加密笔记本查找
for _, encBoxID := range treenode.GetOpenedEncryptedBoxIDs() {View on GitHub (pinned to 8641553a1f)
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
Example fix
// before
ret.Msg = err.Error()
// after
if errors.Is(err, model.ErrBoxUnindexed) {
ret.Code = -1
ret.Msg = "" // kernel already pushed a prompt
} Defensive patterns
Strategy: retry
Validate before calling
if isNotebookClosedOrUnindexed(boxID) {
return fmt.Errorf("notebook %s is not indexed; open or rebuild index first", boxID)
} Try / catch
if errors.Is(err, model.ErrBoxUnindexed) {
// kernel already notified the user; no extra message needed
return
} Prevention
- Open notebooks before querying them in automations
- Run Rebuild Index on restored/imported notebooks
- Wait for initial indexing after workspace restore
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Please unlock the encrypted notebook first
- initialize encrypted notebook document failed: %w
- can not get or create rollback box
- Conf.Language(314)
- encrypted repository data has no matching notebook [%s]
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/aa1a49227e5cce3f.
Report an issue: GitHub.