siyuan-note/siyuan · error
ErrItemNotFound
ErrItemNotFound
Error message
item not found
What it means
ErrItemNotFound is returned when a row (item/block value) with the given itemID does not exist within a key's values — e.g. updateAttributeViewValue finds no blockVal for the item and aborts with av.ErrItemNotFound instead of silently creating a dangling row update.
Source
Thrown at kernel/av/av.go:1344
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")
ErrRichTextSpecMismatch = errors.New("attribute view rich text requires storage spec 9")
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,逗号分隔
NodeAttrContextFilter = "custom-sy-av-context-filter" // 用于保存数据库块独有的上下文筛选配置
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 8641553a1f)
Solutions
- Re-read the AV and confirm the item exists (GetBlockValue / GetValue) before updating
- Check errors.Is(err, av.ErrItemNotFound) and re-create the row if it should exist
- Ensure the itemID comes from the same attribute view as the keyID being targeted
- Refresh the frontend/plugin row cache after any AddAttributeViewBlocksWithValues or remove-blocks operation
Example fix
// before
updateAttributeViewValue(nil, attrView, keyID, missingItemID, val, false) // ErrItemNotFound
// after
if attrView.GetBlockValue(itemID) == nil {
return fmt.Errorf("row %s does not exist in av %s; re-add it first", itemID, attrView.ID)
}
updateAttributeViewValue(nil, attrView, keyID, itemID, val, false) Defensive patterns
Strategy: type-guard
Validate before calling
if attrView.GetBlockValue(itemID) == nil {
return fmt.Errorf("item %s not present in av %s", itemID, attrView.ID)
} Type guard
func itemExists(attrView *av.AttributeView, itemID string) bool {
return attrView.GetBlockValue(itemID) != nil
} Try / catch
err := updateAttrViewValue(avID, keyID, itemID, value)
if errors.Is(err, av.ErrItemNotFound) {
log.Warnf("row %s was deleted; skipping update", itemID)
return nil // or re-add the row via AddAttributeViewBlocksWithValues
} Prevention
- Refresh row caches after any row deletion or database rebuild
- Confirm the itemID belongs to the same attribute view as keyID
- Skip-or-recreate: decide explicitly whether a missing row should be skipped or re-added
When it happens
Trigger: Calling updateAttributeViewValue (or higher-level value-update APIs) with an itemID that has no row in the target key's values — the row was deleted, belongs to another database, or the ID was mistyped; TestUpdateAttributeViewValueRejectsMissingItem asserts this behavior.
Common situations: Plugin holding a row ID while the user deleted the row; updating a row in the wrong attribute view; row IDs from a stale frontend cache after a database rebuild; concurrent deletion racing an update.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/73b6f7fe4782af9a.
Report an issue: GitHub.