siyuan-note/siyuan · error · ErrItemNotFound
item not found
Error message
item not found
What it means
ErrItemNotFound is the sentinel error for a missing row/item in a SiYuan attribute view. It is raised in kernel/model/attribute_view.go:7748 (setAttrViewCellAttrView path) when attrView.GetBlockValue(itemID) returns nil, i.e. no row whose block value binds to itemID exists in the block key-values.
Solutions
- Re-render or re-fetch the database rows and use a current rowID before updating a cell
- Check attrView.GetBlockValue(itemID) or ExistBoundBlock(itemID) before issuing the operation
- Handle errors.Is(err, av.ErrItemNotFound) as a benign skip in transaction handlers so one stale row does not abort the batch
- If rows were deleted by sync, reconcile by reloading the workspace data before retrying
Example fix
// before
err := tx.setAttributeViewCellAttrView(op) // may hit ErrItemNotFound
if err != nil { return err }
// after
if nil == attrView.GetBlockValue(op.RowID) {
return nil // row already gone; nothing to update
}
err := tx.setAttributeViewCellAttrView(op)
if err != nil && strings.Contains(err.Error(), av.ErrItemNotFound.Error()) {
return nil
} Defensive patterns
Strategy: validation
Validate before calling
if !attrView.ExistBoundBlock(rowID) && nil == attrView.GetBlockValue(rowID) {
return nil // row no longer exists; nothing to update
} Type guard
func isItemNotFound(err error) bool {
return errors.Is(err, av.ErrItemNotFound)
} Try / catch
err := applyCellUpdate(op)
if err != nil {
if errors.Is(err, av.ErrItemNotFound) || strings.Contains(err.Error(), av.ErrItemNotFound.Error()) {
// row vanished mid-batch: log, skip, continue with next op
}
} Prevention
- Refresh rowIDs from the current render before editing cells
- Serialize delete-row and update-cell operations through the same transaction queue
- For plugins, hook the database re-render push event and invalidate cached row IDs
When it happens
Trigger: Sending a setAttrViewCellAttrView / cell-update transaction operation with a rowID that was deleted from the database; referencing a detached row that was removed by another client between render and update; passing a block ID that exists in the note but was never bound as a row of this database.
Common situations: Stale editor state after a database was edited in a second window or on another synced device; a plugin caches rowIDs across schema/row changes; delete-row and update-cell operations race in the transaction queue.
Related errors
- key not found
- view not found
- attribute view [ ] not found in box [ ]
- attribute view spec is too new
- filter nesting depth exceeds the maximum allowed
AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18).
Data as JSON: /api/errors/35c28e8ad440ea96.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/av.go:1298
if err := os.MkdirAll(av, 0755); err != nil {
logging.LogErrorf("create attribute view dir failed: %s", err)
return
}
}
return
}
func GetAttributeViewI18n(key string) string {
return util.AttrViewLangs[util.Lang][key].(string)
}
var (
ErrAttributeViewNotFound = errors.New("attribute view not found")
ErrInvalidAttributeViewID = errors.New("invalid attribute view id")
ErrInvalidBoxID = errors.New("invalid box id")
ErrViewNotFound = errors.New("view not found")
ErrKeyNotFound = errors.New("key not found")
ErrItemNotFound = errors.New("item not found")
ErrWrongLayoutType = errors.New("wrong layout type")
ErrInvalidColumnAlign = errors.New("invalid column align")
ErrSpecTooNew = errors.New("attribute view spec is too new")
ErrFilterTooDeep = errors.New("filter nesting depth exceeds the maximum allowed")
)
const (
NodeAttrNameAvs = "custom-avs" // 用于标记块所属的属性视图,逗号分隔 av id
NodeAttrView = "custom-sy-av-view" // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443
NodeAttrVisibleViewIDs = "custom-sy-av-visible-views" // 用于标记数据库块显示的视图 ID,逗号分隔
NodeAttrViewStaticText = "custom-sy-av-s-text" // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049
NodeAttrViewNames = "av-names" // 用于临时标记块所属的属性视图名称,空格分隔
)
View on GitHub (pinned to afa823b6b4)