siyuan-note/siyuan · error

clone attribute view text value [%s] failed

Error message

clone attribute view text value [%s] failed

What it means

When updating an attribute view text value, the kernel clones the existing value before merging the incoming JSON so the original is not polluted by failed validation. This error is thrown if val.Clone() returns nil, meaning the source text value could not be cloned and the update cannot proceed safely.

Source

Thrown at kernel/model/attribute_view.go:8192

	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 {
		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.KeyTypeText == updatedVal.Type && nil != updatedVal.Text {
		if nil != oldText && nil != oldText.Rich && !attributeViewTextRichFieldPresent(data) &&
			updatedVal.Text.Content != oldText.Content {
			updatedVal.Text.Rich = nil
		}
		if err = updatedVal.Text.NormalizeRichContent(); nil != err {

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Re-index or reload the attribute view so the value object exists, then retry
  2. Verify the valueID refers to an existing value of the text key
  3. Recreate the row/value if the underlying data is corrupted
Defensive patterns

Strategy: try-catch

Validate before calling

const val = getValue(avID, keyID, valueID); if (!val) throw new Error("value not found: " + valueID);

Try / catch

try { await updateValue(data); } catch (e) { if (String(e).includes("clone attribute view text value")) { await reloadAttrView(avID); retryOnce(); } else throw e; }

Prevention

When it happens

Trigger: Calling the update-attribute-view-value API for a KeyTypeText column when the in-memory value object is nil or in a state where Clone() yields nil (e.g. corrupted/missing value entry for the given valueID).

Common situations: Stale valueID referencing a deleted row value; concurrent deletion during the update; index inconsistency after a failed sync.

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@8641553a1f (2026-09-11). Data as JSON: /api/errors/c8ce8814bce9068c. Report an issue: GitHub.