siyuan-note/siyuan · warning

invalid card configuration value [%v]

Error message

invalid card configuration value [%v]

What it means

Returned by getAttrViewOperationNumber (attribute_view.go:1824), the shared helper used by setAttrViewCardAspectRatio, setAttrViewCardAspectRatioValue, setAttrViewCardSize, setAttrViewCardWidth, and setAttrViewCardLayout. It type-asserts operation.Data to float64; Go's encoding/json decodes JSON numbers into float64, so any non-numeric payload (string, bool, null, array, object) fails the assertion and yields this error before any range check.

Source

Thrown at kernel/model/attribute_view.go:1824

	err = av.SaveAttributeView(attrView)
	return
}

func getAttrViewOperationView(attrView *av.AttributeView, operation *Operation) (ret *av.View, err error) {
	if "" != operation.ViewID {
		ret = attrView.GetView(operation.ViewID)
		if nil == ret {
			err = av.ErrViewNotFound
		}
		return
	}
	return getAttrViewViewByBlockID(attrView, operation.BlockID)
}

func getAttrViewOperationNumber(operation *Operation) (ret float64, err error) {
	var ok bool
	if ret, ok = operation.Data.(float64); !ok {
		err = fmt.Errorf("invalid card configuration value [%v]", operation.Data)
	}
	return
}

func (tx *Transaction) doSetAttrViewCoverFromAssetKeyID(operation *Operation) (ret *TxErr) {
	err := setAttrViewCoverFromAssetKeyID(operation)
	if err != nil {
		return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
	}
	return
}

func setAttrViewCoverFromAssetKeyID(operation *Operation) (err error) {
	attrView, err := av.ParseAttributeView(operation.AvID)
	if err != nil {
		return
	}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Send operation.data as a JSON number for any of the five card-numeric actions.
  2. Coerce with Number() / parseFloat on the client before building the transaction.
  3. If you see this error, switch focus from the value's range to its JSON type — the guard is purely a type assertion.

Example fix

// before: input.value is a string
transaction({ op: "setAttrViewCardWidth", data: inputEl.value })

// after: coerce to a number
transaction({ op: "setAttrViewCardWidth", data: Number(inputEl.value) })
Defensive patterns

Strategy: type-guard

Validate before calling

// Coerce to a JSON number before building any card-numeric operation.
const num = Number(value)
if (!Number.isFinite(num)) throw new Error('card config value must be a finite number')
op.data = num

Type guard

function isCardConfigNumber(v: unknown): v is number {
  return typeof v === 'number' && Number.isFinite(v)
}

Prevention

When it happens

Trigger: Any of the five card-numeric actions receives an operation.data that is not a JSON number — e.g. a string "2", a boolean, null, or an object. Because the assertion happens first, you never reach the per-action range/enum guards (errors 426/427/432/433/434) when the type is wrong.

Common situations: Frontend serializes the value as a string (e.g. from an input element's value without Number()); plugin sends null as a "reset"; a generic operation builder boxes numbers in objects; JSON built manually with a quoted number.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/a3355cbccffb64c0. Report an issue: GitHub.