siyuan-note/siyuan · error

invalid card cover source

Error message

invalid card cover source [%s]

What it means

setAttrViewCardCoverPosition parses a setAttrViewCardCoverPositionData payload and validates the cover source against av.IsValidCardCoverSource. If the requested source is not a recognized card cover source enum value, this error is thrown. It guards the card-cover feature (gallery/kanban views) against unknown source identifiers.

Solutions

  1. Use a valid card cover source value as accepted by av.IsValidCardCoverSource (e.g. the field-based or uploaded-image constants exposed by the av package).
  2. Check the view's current gallery.coverFrom / kanban.coverFrom to mirror a valid value.
  3. Update the client/plugin to the current av constants if it was written against an older API version.

Example fix

// before
{ "source": "custom-image" } // unrecognized
// after
{ "source": "upload" } // a value valid per av.IsValidCardCoverSource
Defensive patterns

Strategy: validation

Validate before calling

const VALID_SOURCES = ["none", "field", "upload"]; // mirror av.IsValidCardCoverSource
if (!VALID_SOURCES.includes(source)) throw new Error(`unsupported cover source: ${source}`);

Type guard

const isCoverSource = (v: string): boolean => ["none", "field", "upload"].includes(v);

Try / catch

try { await setCardCoverPosition(...); } catch (e) { if (String(e).includes("invalid card cover source")) resetToViewDefaults(); else throw e; }

Prevention

When it happens

Trigger: Invoking doSetAttrViewCardCoverPosition with data.source set to an invalid or misspelled value, e.g. "asset" instead of the valid enum constants, or an empty/legacy value no longer accepted.

Common situations: Plugins hard-coding cover source strings instead of using the exported constants; version drift where an older client sends a source value the newer kernel removed; typos in JSON payloads.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/attribute_view.go:2061

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