siyuan-note/siyuan · error
clone attribute view item failed
Error message
clone attribute view item failed
What it means
newBoundAttributeViewItemValue clones the original detached value and rewrites it into a bound value pointing at the new document. It errors when Clone() returns nil or the clone has no Block field, because a block-type value without Block data cannot be converted to a bound (non-detached) reference. Callers wrap this with the item ID (see error 1002).
Solutions
- Verify the item's primary-key value in the .av JSON has a non-null block object; recreate the row if it is missing
- Reload/re-index the database so the value is re-read from disk, then retry the conversion
- In tests, construct the input av.Value with a non-nil Block before calling newBoundAttributeViewItemValue
Example fix
// before
bound := original.Clone()
if nil == bound || nil == bound.Block {
return nil, errors.New("clone attribute view item failed")
}
// after (caller-side guard)
if original == nil || original.Block == nil {
return nil, fmt.Errorf("item value has no block data")
}
bound := original.Clone() Defensive patterns
Strategy: type-guard
Validate before calling
if original == nil || original.Block == nil { return errors.New("value has no block data") } Type guard
func hasBlockValue(v *av.Value) bool { return v != nil && v.Block != nil } Try / catch
bound, err := newBoundAttributeViewItemValue(original, docID, icon)
if err != nil { return fmt.Errorf("item %s not bindable: %w", itemID, err) } Prevention
- Ensure fixture/row values always carry a non-nil Block for block-type keys
- Validate .av JSON after external edits
- Re-index databases that fail this check
When it happens
Trigger: Called from CreateAttributeViewItemDocs for an item whose value.Clone() yields nil, or whose primary-key (block) value lacks the Block struct after cloning — typically due to corrupted attribute-view row data.
Common situations: Hand-edited .av JSON; rows produced by older format versions missing Block; test fixture data (this function is directly exercised by TestNewBoundAttributeViewItemValueUsesDynamicAnchorText) with a value whose Block is nil.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- clone attribute view item
- bind attribute view item
- clone attribute view value
- invalid create attribute view item documents save mode
- new attribute view item document in an encrypted notebook…
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/07b8d46acca15409.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view_new_item.go:337
var cleanupErr error
for _, item := range items {
_, _, detachErr := replaceAttributeViewBlock(avID, item.itemID, "", true, nil)
cleanupErr = errors.Join(cleanupErr, detachErr)
_, restoreErr := UpdateAttributeViewCell(nil, avID, item.original.KeyID, item.itemID, item.original)
cleanupErr = errors.Join(cleanupErr, restoreErr)
}
cleanupErr = errors.Join(cleanupErr, cleanupCreatedDocs())
ReloadAttrView(avID)
return nil, newItemCreationError(err, cleanupErr)
}
ret.Transaction = tx
return ret, nil
}
func newBoundAttributeViewItemValue(original *av.Value, docID, icon string) (*av.Value, error) {
bound := original.Clone()
if nil == bound || nil == bound.Block {
return nil, errors.New("clone attribute view item failed")
}
bound.IsDetached = false
bound.Block.ID = docID
bound.Block.Content = ""
bound.Block.Icon = icon
bound.Block.RefSubtype = av.BlockRefSubtypeDynamic
return bound, nil
}
func lockAttributeViewItemDocs(avID string) func() {
lockValue, _ := attributeViewItemDocsLocks.LoadOrStore(avID, &sync.Mutex{})
lock := lockValue.(*sync.Mutex)
lock.Lock()
return lock.Unlock
}
func attributeViewItemDocumentTemplate(attrView *av.AttributeView, saveMode string) (*av.NewItemTemplate, error) {
switch saveMode {View on GitHub (pinned to 9f775e8a12)