siyuan-note/siyuan · warning
invalid card cover source [%s]
Error message
invalid card cover source [%s]
What it means
Returned by setAttrViewCardCoverPosition (attribute_view.go:1915), dispatched through the transaction action "setAttrViewCardCoverPosition". After unmarshaling operation.Data into setAttrViewCardCoverPositionData, it validates data.Source via av.IsValidCardCoverSource. A valid source is either the literal "content" (CardCoverSourceContent) or the prefix "asset:" followed by a string matching ast.IsNodeIDPattern (a 14+-digit timestamp-style ID). Any other value fails.
Source
Thrown at kernel/model/attribute_view.go:1915
func (tx *Transaction) doSetAttrViewCardCoverPosition(operation *Operation) (ret *TxErr) {
if err := setAttrViewCardCoverPosition(operation); nil != err {
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
}
return
}
func setAttrViewCardCoverPosition(operation *Operation) (err error) {
dataJSON, err := json.Marshal(operation.Data)
if nil != err {
return
}
var data setAttrViewCardCoverPositionData
if err = json.Unmarshal(dataJSON, &data); nil != err {
return
}
if !av.IsValidCardCoverSource(data.Source) {
return fmt.Errorf("invalid card cover source [%s]", data.Source)
}
if nil != data.Position {
if "" == data.Position.Image || 32*1024 < len(data.Position.Image) {
return errors.New("invalid card cover image")
}
if math.IsNaN(data.Position.X) || math.IsInf(data.Position.X, 0) ||
math.IsNaN(data.Position.Y) || math.IsInf(data.Position.Y, 0) ||
data.Position.X < 0 || 100 < data.Position.X || data.Position.Y < 0 || 100 < data.Position.Y {
return fmt.Errorf("invalid card cover position [%v, %v]", data.Position.X, data.Position.Y)
}
}
attrView, err := av.ParseAttributeView(operation.AvID)
if nil != err {
return
}
if nil == attrView.GetBlockValue(operation.RowID) {
return fmt.Errorf("attribute view item [%s] not found", operation.RowID)View on GitHub (pinned to 251596fc0d)
Solutions
- Build the source with av.CardCoverSource(coverFrom, assetKeyID): "content" for content images, "asset:<keyID>" for an asset field — and use the same keyID the view was configured with.
- Send source = "content" exactly (lowercase, no prefix) for the content-image cover mode.
- If the asset field was removed, clear the cover (CoverFromNone) instead of sending a stale asset source.
Example fix
// before: hand-built source string
transaction({ op: "setAttrViewCardCoverPosition", data: { source: "asset:" + fieldId, position } })
// after: derive source consistently with the view's cover config
const source = coverFrom === "asset" ? `asset:${view.coverFromAssetKeyID}` : "content"
transaction({ op: "setAttrViewCardCoverPosition", data: { source, position } }) Defensive patterns
Strategy: validation
Validate before calling
// Build the source the same way the renderer does.
const source = coverFrom === 'asset' ? `asset:${view.coverFromAssetKeyID}` : 'content'
if (!/^content$|^asset:\d{14,}$/.test(source)) throw new Error('invalid card cover source') Type guard
function isValidCardCoverSource(s: unknown): boolean {
if (typeof s !== 'string') return false
if (s === 'content') return true
return /^asset:\d{14,}$/.test(s)
} Prevention
- Derive the source from av.CardCoverSource(coverFrom, assetKeyID), not by hand.
- Use exactly "content" (lowercase) for the content-image mode.
- Clear the cover (CoverFromNone) instead of sending a stale asset source when the field is gone.
When it happens
Trigger: Frontend sends a cover position update whose source is empty, misspelled (e.g. "contents"), or an asset key without a valid node-ID suffix (e.g. "asset:abc"). The source must match how the cover was configured (CoverFrom + CoverFromAssetKeyID) and is re-checked against the view later (a mismatch yields "card cover source does not match view").
Common situations: Plugin constructs the source string by hand and gets the format wrong; UI sends an empty source when no cover is selected but still attaches a position object; keyID was deleted so the source became invalid.
Related errors
- invalid card cover image
- invalid card aspect ratio preset [%v]
- invalid card aspect ratio [%v]
- invalid card size preset [%v]
- invalid card width [%v]
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/0da580f16a88112d.
Report an issue: GitHub.