siyuan-note/siyuan · error

ErrItemNotFound

ErrItemNotFound

Error message

item not found

What it means

ErrItemNotFound signals that a block value/row (item) referenced by an id does not exist in the attribute view. Binding preflight (preflightAttributeViewCellBindings), binding replacement, and value updates raise it when GetBlockValue returns nil for the row id.

Solutions

  1. Check that the row/block id still exists (GetBlockValue != nil) before updating or binding
  2. Clean up orphaned bindings/rows after block deletion in the same transaction
  3. Refresh the attribute view snapshot before writing so stale ids are not used

Example fix

// before
original := attrView.GetBlockValue(cell.RowID)
value = original.Clone()
// after
original := attrView.GetBlockValue(cell.RowID)
if original == nil {
    return av.ErrItemNotFound
}
value = original.Clone()
Defensive patterns

Strategy: validation

Validate before calling

if attrView.GetBlockValue(rowID) == nil {
    return fmt.Errorf("row %s missing", rowID)
}

Try / catch

if err := bindCells(...); err != nil {
    if errors.Is(err, av.ErrItemNotFound) {
        // drop the stale binding and resync rows
    }
}

Prevention

When it happens

Trigger: UpdateAttributeViewValue with a row id that was deleted; replaceAttributeViewBinding when the original block value is gone; attribute_view_binding.go cloning the original value of a cell whose row no longer exists.

Common situations: A bound block was deleted (or its id changed via copy/paste) while database rows still reference it; interrupted sync removed rows but not bindings; plugin writes to a row id from an outdated snapshot.

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@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/73b6f7fe4782af9a. Report an issue: GitHub.

Appendix: source

Thrown at kernel/av/av.go:1388

		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 9f775e8a12)