siyuan-note/siyuan · warning
ErrBoxUnindexed
ErrBoxUnindexed
Error message
notebook unindexed
What it means
ErrBoxUnindexed is a sentinel error in the SiYuan kernel's model package meaning the requested notebook (box) exists and is open, but its content has not been indexed yet, so tree/block lookups cannot be served from the index. The kernel throws it instead of silently rebuilding the index because indexing is expensive and the UI is separately notified. Callers such as the block API treat it as 'user already warned' and suppress a duplicate error message.
Solutions
- Wait for indexing to finish: retry after the notebook's index queue drains, or call the index API (e.g. /api/filetree/index) for the box first
- Check the notebook is open and indexed via /api/notebook/lsNotebooks before issuing block/tree lookups
- If the index is persistently missing, trigger a full reindex (Reindex / rebuildIndex) and retry
- Handle the sentinel with errors.Is(err, model.ErrBoxUnindexed) and rely on the already-pushed UI message instead of surfacing a new error
Example fix
// before
msg := err.Error()
// after
if errors.Is(err, model.ErrBoxUnindexed) {
return // 提示已在加载时推送,忽略即可
} Defensive patterns
Strategy: retry
Validate before calling
const nb = notebooks.find(nb => nb.id === boxID); if (!nb || nb.closed) abort(); /* else wait for indexing queue to drain before querying */
Type guard
func isBoxUnindexed(err error) bool { return errors.Is(err, model.ErrBoxUnindexed) } Try / catch
if errors.Is(err, model.ErrBoxUnindexed) {
// UI 提示已推送,静默等待索引完成或稍后重试
return nil
} Prevention
- Wait for initial indexing to complete before issuing block/tree queries after boot
- Reopen/re-index a notebook explicitly after closing or restoring it
- Poll notebook status instead of assuming index readiness
When it happens
Trigger: Calling load-tree or block lookup APIs (e.g. /api/filetree/getDoc, setGetBlockInfoError paths, indexTreeInFilesystem0) with a block ID whose notebook has no index yet — typically right after opening a workspace, re-enabling a closed notebook, or before the initial indexing pass finishes.
Common situations: Starting the kernel and immediately querying blocks; switching notebooks that were closed and reopened; a workspace restored from backup or sync where blocks/index tables are still being rebuilt.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- block [ ] is not a sortable document
- encrypted attribute view snapshot has no matching notebook
- encrypted notebook key material is missing
- ErrBoxClosed
- ErrBoxNotFound
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/aa1a49227e5cce3f.
Report an issue: GitHub.
Appendix: 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 9f775e8a12)