{"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":1418,"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":1400,"sourceCodeEnd":1436,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view.go#L1400-L1436","documentation":"The node identified by blockID must be an ast.NodeAttributeView block whose AttributeViewID equals the given avID. If the block is a different node type, or belongs to a different attribute view, the kernel refuses to write the visible-view IDs attribute onto it.","triggerScenarios":"Calling SetDatabaseBlockVisibleViews with a blockID pointing to a paragraph/heading/other block, or to a database block whose attribute view ID differs from the avID argument.","commonSituations":"Passing a container/parent block ID instead of the database block ID; block was converted to another type; avID copied from another database after copy-pasting blocks; stale references after undo/redo.","solutions":["Verify the block is a database block (type 'NodeAttributeView' in the .sy tree) and read its own avID from node.AttributeViewID / the block's 'av' attribute before calling.","Use the avID that belongs to the given blockID, not an unrelated attribute view.","Re-resolve the block by ID after edits; if the block no longer exists as a database, surface a user-facing error instead of retrying."],"exampleFix":"// before\nsetVisibleViews(someBlockId, avIdFromMemory, viewIds);\n// after\nconst node = getNode(blockId);\nif (node && node.type === 'NodeAttributeView') {\n  setVisibleViews(blockId, node.avId, viewIds);\n}","handlingStrategy":"type-guard","validationCode":"const node = getNode(blockID);\nif (!node || node.type !== 'NodeAttributeView' || node.avId !== avID) throw new Error('block is not an instance of this attribute view');","typeGuard":"const isAttrViewNode = (n: { type: string; avId?: string } | null, avID: string): boolean => !!n && n.type === 'NodeAttributeView' && n.avId === avID;","tryCatchPattern":"try { await setVisibleViews(blockID, avID, viewIDs); } catch (e) { if (String(e).includes('is not an instance of attribute view')) { console.warn('block/av mismatch', blockID, avID); } else throw e; }","preventionTips":["Read the avID from the database block itself (node.AttributeViewID) instead of passing it independently","Re-resolve block IDs after undo/redo or block-type conversion","Never reuse an avID across copied blocks without re-reading it"],"tags":["attribute-view","type-mismatch","block-validation"],"backgroundTag":"incompatible-source-type","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"}