{"record":{"id":"f747551e5f3f03a0","repo":"siyuan-note/siyuan","slug":"block-s-is-not-an-instance-of-attribute-view","errorCode":null,"errorMessage":"block [%s] is not an instance of attribute view [%s]","messagePattern":"block \\[(.+?)\\] is not an instance of attribute view \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":1272,"sourceCode":"\t\tvisible[viewID] = true\n\t}\n\n\tvar normalized []string\n\tfor _, view := range attrView.Views {\n\t\tif visible[view.ID] {\n\t\t\tnormalized = append(normalized, view.ID)\n\t\t}\n\t}\n\tif 1 > len(normalized) {\n\t\treturn errors.New(\"at least one visible view is required\")\n\t}\n\n\tnode, tree, err := getNodeByBlockID(nil, blockID)\n\tif nil != err {\n\t\treturn\n\t}\n\tif ast.NodeAttributeView != node.Type || node.AttributeViewID != avID {\n\t\treturn fmt.Errorf(\"block [%s] is not an instance of attribute view [%s]\", blockID, avID)\n\t}\n\n\terr = setNodeAttrs(node, tree, map[string]string{\n\t\tav.NodeAttrVisibleViewIDs: strings.Join(normalized, \",\"),\n\t})\n\treturn\n}\n\nfunc (tx *Transaction) doChangeAttrViewLayout(operation *Operation) (ret *TxErr) {\n\terr := ChangeAttrViewLayout(operation.BlockID, operation.AvID, operation.Layout)\n\tif err != nil {\n\t\treturn &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}\n\t}\n\treturn\n}\n\nfunc ChangeAttrViewLayout(blockID, avID string, newLayout av.LayoutType) (err error) {\n\tattrView, err := av.ParseAttributeView(avID)","sourceCodeStart":1254,"sourceCodeEnd":1290,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/attribute_view.go#L1254-L1290","documentation":"Returned by SetDatabaseBlockVisibleViews (attribute_view.go:1272) when the block referenced by blockID is either not a NodeAttributeView node or its AttributeViewID attribute does not equal the supplied avID. The lookup uses getNodeByBlockID; the type/ID mismatch means the block is not the database block that owns this attribute view.","triggerScenarios":"Calling setAttrViewBlockVisibleViews with a blockID that points to a paragraph/list/heading rather than a database block, or with a blockID whose embedded database (AttributeViewID) differs from operation.AvID — e.g. the block mirrors a different avID, or the IDs were swapped.","commonSituations":"Frontend sends the avID of one database but the blockID of a block embedding another; copy-paste of a database block where the new block got a new avID but the UI still references the old one; plugin mismatch after mirroring.","solutions":["Send the blockID and avID that actually belong together — read them from the same NodeAttributeView node (node.AttributeViewID paired with the block's ID).","If the block mirrors multiple databases, target the specific mirror's avID, not the canonical one.","Validate node.Type == NodeAttributeView and node.AttributeViewID == avID client-side before submitting."],"exampleFix":"// before: avID taken from the wrong source\ntransaction({ op: \"setAttrViewBlockVisibleViews\", blockID, avID: lastOpenedAvID, viewIDs })\n\n// after: read the pair from the node itself\nconst node = getBlockNode(blockID)\ntransaction({ op: \"setAttrViewBlockVisibleViews\", blockID, avID: node.attributeViewID, viewIDs })","handlingStrategy":"validation","validationCode":"// Pair blockID with the avID stored on that exact block node.\nconst node = await fetchBlockAttrs(blockID)\nif (node.type !== 'NodeAttributeView' || node.attributeViewID !== avID) {\n  throw new Error('block is not an instance of this attribute view')\n}","typeGuard":"function blockOwnsAv(node: BlockAttrs, avID: string): boolean {\n  return node.type === 'NodeAttributeView' && node.attributeViewID === avID\n}","tryCatchPattern":null,"preventionTips":["Read avID from the same NodeAttributeView node whose ID is blockID.","For mirrored databases, target each mirror's own avID pairing.","Do not reuse an avID from a different database block."],"tags":["attribute-view","av","database","block","validation","transaction"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}