siyuan-note/siyuan · error

clone attribute view text value

Error message

clone attribute view text value [%s] failed

What it means

When updating an attribute view cell value of type text or block, the kernel clones the existing value and merges/validates incoming JSON against the clone so a failed validation doesn't corrupt the stored value. If val.Clone() returns nil, the kernel cannot construct the working copy and returns this formatted error including the value ID.

Solutions

  1. Refresh the attribute view (re-fetch it) to get current value IDs, then retry with a valid valueID
  2. Verify the valueID exists in the target key's values before updating
  3. Re-index or repair the .av file if the value object is corrupted (rebuild via data reindex)
  4. Check for concurrent modification and serialize updates to the same view

Example fix

// before
fetch("/api/av/setAttributeViewBlockAttr", {body: {valueID: staleID, ...}})
// after
const av = await getAttrView(avID); // re-fetch and confirm the value exists
if (!findValue(av, valueID)) throw new Error("stale valueID");
fetch("/api/av/setAttributeViewBlockAttr", {body: {valueID, ...}})
Defensive patterns

Strategy: retry

Validate before calling

const exists = attrView.KeyValues.some(kv => kv.Key.Values.some(v => v.ID === valueID));
if (!exists) throw new Error(`stale or unknown valueID: ${valueID}`);

Try / catch

try { await setBlockAttr(op); } catch (e) { if (String(e).includes("clone attribute view text value")) { await refreshAttrView(); retry(op); } else { throw e; } }

Prevention

When it happens

Trigger: Calling the cell value update API for a text or block (primary key) cell whose current value object fails to clone (nil result from Clone), i.e. the in-memory value is missing or in an unexpected state.

Common situations: Stale client cache: the value ID refers to a cell removed/changed by another client; corrupted .av data where the value object is incomplete; race between deleting a row and updating its cell.

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


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/c8ce8814bce9068c. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/attribute_view.go:8158

	var oldRelationBlockIDs []string
	if av.KeyTypeRelation == val.Type {
		if nil != val.Relation {
			for _, bID := range val.Relation.BlockIDs {
				oldRelationBlockIDs = append(oldRelationBlockIDs, bID)
			}
		}
	}
	data, err := gulu.JSON.MarshalJSON(valueData)
	if err != nil {
		logging.LogErrorf("marshal value [%+v] failed: %s", valueData, err)
		return
	}
	updatedVal := val
	// 文本和主键值先在副本上合并和校验,避免校验失败污染原值,并保留部分更新语义。
	if av.KeyTypeText == valueType || av.KeyTypeBlock == valueType {
		updatedVal = val.Clone()
		if nil == updatedVal {
			err = fmt.Errorf("clone attribute view text value [%s] failed", valueID)
			return
		}
	}
	if err = gulu.JSON.UnmarshalJSON(data, updatedVal); err != nil {
		logging.LogErrorf("unmarshal data [%s] failed: %s", data, err)
		return
	}
	updatedVal.ID = valueID
	updatedVal.KeyID = keyID
	updatedVal.BlockID = itemID
	updatedVal.Type = valueType
	updatedVal.CreatedAt = valueCreatedAt
	if av.KeyTypeBlock == valueType && !updatedVal.IsDetached {
		if updatedVal.Block == nil {
			return nil, ErrBlockNotFound
		}
		_, tree, loadErr := getNodeByBlockID(tx, updatedVal.Block.ID)
		if loadErr != nil {

View on GitHub (pinned to 9f775e8a12)