{"record":{"id":"a3355cbccffb64c0","repo":"siyuan-note/siyuan","slug":"invalid-card-configuration-value-v","errorCode":null,"errorMessage":"invalid card configuration value [%v]","messagePattern":"invalid card configuration value \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":1970,"sourceCode":"\terr = av.SaveAttributeView(attrView)\n\treturn\n}\n\nfunc getAttrViewOperationView(attrView *av.AttributeView, operation *Operation) (ret *av.View, err error) {\n\tif \"\" != operation.ViewID {\n\t\tret = attrView.GetView(operation.ViewID)\n\t\tif nil == ret {\n\t\t\terr = av.ErrViewNotFound\n\t\t}\n\t\treturn\n\t}\n\treturn getAttrViewViewByBlockID(attrView, operation.BlockID)\n}\n\nfunc getAttrViewOperationNumber(operation *Operation) (ret float64, err error) {\n\tvar ok bool\n\tif ret, ok = operation.Data.(float64); !ok {\n\t\terr = fmt.Errorf(\"invalid card configuration value [%v]\", operation.Data)\n\t}\n\treturn\n}\n\nfunc (tx *Transaction) doSetAttrViewCoverFromAssetKeyID(operation *Operation) (ret *TxErr) {\n\terr := setAttrViewCoverFromAssetKeyID(operation)\n\tif err != nil {\n\t\treturn &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}\n\t}\n\treturn\n}\n\nfunc setAttrViewCoverFromAssetKeyID(operation *Operation) (err error) {\n\tattrView, err := av.ParseAttributeView(operation.AvID)\n\tif err != nil {\n\t\treturn\n\t}\n","sourceCodeStart":1952,"sourceCodeEnd":1988,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view.go#L1952-L1988","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Send the card configuration value as a JSON number in operation.Data (e.g. 1.5, not \"1.5\").","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.","Log operation.Data before the call to confirm the actual payload type the client is sending."],"exampleFix":"// before\n{ \"data\": \"1.5\" } // string value\n// after\n{ \"data\": 1.5 } // JSON number","handlingStrategy":"type-guard","validationCode":"if (typeof value !== \"number\" || Number.isNaN(value)) throw new Error(\"card config value must be a number\");","typeGuard":"const isNumber = (v: unknown): v is number => typeof v === \"number\" && !Number.isNaN(v);","tryCatchPattern":"try { await sendTransaction(op); } catch (e) { if (String(e).includes(\"invalid card configuration value\")) coerceAndRetry(Number(value)); else throw e; }","preventionTips":["Always send JSON numbers, never quoted numbers, in transaction Data","Coerce input-field strings with Number() before building operations","Add client-side schema validation on operation payloads"],"tags":["attribute-view","transaction","type-mismatch"],"backgroundTag":"invalid-argument-value","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}