siyuan-note/siyuan · error

invalid card configuration value

Error message

invalid card configuration value [%v]

What it means

getAttrViewOperationNumber extracts a numeric (float64) payload from a transaction Operation and fails when operation.Data is not a JSON number. Card-configuration operations (aspect ratio, card size, card width, card layout) must send their value as a number; anything else (string, bool, missing) triggers this error. It is a strict input-type guard on the transaction payload.

Solutions

  1. Send the card configuration value as a JSON number in operation.Data (e.g. 1.5, not "1.5").
  2. If the source is JavaScript, ensure the value is a real number, not a string from an input field — coerce with Number(value) before building the transaction.
  3. Log operation.Data before the call to confirm the actual payload type the client is sending.

Example fix

// before
{ "data": "1.5" } // string value
// after
{ "data": 1.5 } // JSON number
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof value !== "number" || Number.isNaN(value)) throw new Error("card config value must be a number");

Type guard

const isNumber = (v: unknown): v is number => typeof v === "number" && !Number.isNaN(v);

Try / catch

try { await sendTransaction(op); } catch (e) { if (String(e).includes("invalid card configuration value")) coerceAndRetry(Number(value)); else throw e; }

Prevention

When it happens

Trigger: Calling the transaction APIs doSetAttrViewCardAspectRatio / doSetAttrViewCardAspectRatioValue / doSetAttrViewCardSize / doSetAttrViewCardWidth / doSetAttrViewCardLayout with operation.Data set to a string like "1.5", an object, a boolean, or omitted instead of a JSON number.

Common situations: Frontend/plugin code building the Operation manually and quoting the numeric value; API consumers sending JSON strings where numbers are expected; schema drift between an older client and a kernel that added strict type checking.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/attribute_view.go:1970

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