{"record":{"id":"0da580f16a88112d","repo":"siyuan-note/siyuan","slug":"invalid-card-cover-source-s","errorCode":null,"errorMessage":"invalid card cover source [%s]","messagePattern":"invalid card cover source \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":2061,"sourceCode":"\nfunc (tx *Transaction) doSetAttrViewCardCoverPosition(operation *Operation) (ret *TxErr) {\n\tif err := setAttrViewCardCoverPosition(operation); nil != err {\n\t\treturn &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}\n\t}\n\treturn\n}\n\nfunc setAttrViewCardCoverPosition(operation *Operation) (err error) {\n\tdataJSON, err := json.Marshal(operation.Data)\n\tif nil != err {\n\t\treturn\n\t}\n\tvar data setAttrViewCardCoverPositionData\n\tif err = json.Unmarshal(dataJSON, &data); nil != err {\n\t\treturn\n\t}\n\tif !av.IsValidCardCoverSource(data.Source) {\n\t\treturn fmt.Errorf(\"invalid card cover source [%s]\", data.Source)\n\t}\n\tif nil != data.Position {\n\t\tif \"\" == data.Position.Image || 32*1024 < len(data.Position.Image) {\n\t\t\treturn errors.New(\"invalid card cover image\")\n\t\t}\n\t\tif math.IsNaN(data.Position.X) || math.IsInf(data.Position.X, 0) ||\n\t\t\tmath.IsNaN(data.Position.Y) || math.IsInf(data.Position.Y, 0) ||\n\t\t\tdata.Position.X < 0 || 100 < data.Position.X || data.Position.Y < 0 || 100 < data.Position.Y {\n\t\t\treturn fmt.Errorf(\"invalid card cover position [%v, %v]\", data.Position.X, data.Position.Y)\n\t\t}\n\t}\n\n\tattrView, err := av.ParseAttributeView(operation.AvID)\n\tif nil != err {\n\t\treturn\n\t}\n\tif nil == attrView.GetBlockValue(operation.RowID) {\n\t\treturn fmt.Errorf(\"attribute view item [%s] not found\", operation.RowID)","sourceCodeStart":2043,"sourceCodeEnd":2079,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view.go#L2043-L2079","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","Check the view's current gallery.coverFrom / kanban.coverFrom to mirror a valid value.","Update the client/plugin to the current av constants if it was written against an older API version."],"exampleFix":"// before\n{ \"source\": \"custom-image\" } // unrecognized\n// after\n{ \"source\": \"upload\" } // a value valid per av.IsValidCardCoverSource","handlingStrategy":"validation","validationCode":"const VALID_SOURCES = [\"none\", \"field\", \"upload\"]; // mirror av.IsValidCardCoverSource\nif (!VALID_SOURCES.includes(source)) throw new Error(`unsupported cover source: ${source}`);","typeGuard":"const isCoverSource = (v: string): boolean => [\"none\", \"field\", \"upload\"].includes(v);","tryCatchPattern":"try { await setCardCoverPosition(...); } catch (e) { if (String(e).includes(\"invalid card cover source\")) resetToViewDefaults(); else throw e; }","preventionTips":["Use the exported av constants instead of hard-coded strings","Mirror coverFrom values read from the live view instead of caching them","Keep plugins updated when kernel enum values change"],"tags":["attribute-view","card-cover","invalid-enum"],"backgroundTag":"invalid-enum-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"}