{"record":{"id":"7f1def2ae2629400","repo":"siyuan-note/siyuan","slug":"attribute-view-s-view-s-not-found","errorCode":null,"errorMessage":"attribute view [%s] view [%s] not found","messagePattern":"attribute view \\[(.+?)\\] view \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template.go","lineNumber":495,"sourceCode":"\nfunc templateAttributeViewMode(node *ast.Node) (ret TemplateDatabaseMode, err error) {\n\tvalue := strings.TrimSpace(node.IALAttr(templateDatabaseModeAttr))\n\tif \"\" == value {\n\t\treturn TemplateDatabaseModeCopy, nil\n\t}\n\tret = TemplateDatabaseMode(value)\n\tif TemplateDatabaseModeCopy != ret && TemplateDatabaseModeReference != ret {\n\t\treturn \"\", fmt.Errorf(\"unsupported template database mode [%s]\", value)\n\t}\n\treturn\n}\n\nfunc validateTemplateAttributeViewNode(node *ast.Node, attrView *av.AttributeView) (selectedView *av.View, err error) {\n\tviewID := strings.TrimSpace(node.IALAttr(av.NodeAttrView))\n\tif \"\" != viewID {\n\t\tselectedView = attrView.GetView(viewID)\n\t\tif nil == selectedView {\n\t\t\treturn nil, fmt.Errorf(\"attribute view [%s] view [%s] not found\", attrView.ID, viewID)\n\t\t}\n\t} else if selectedView, err = attrView.GetFirstView(); nil != err {\n\t\treturn nil, fmt.Errorf(\"attribute view [%s] has no available view: %w\", attrView.ID, err)\n\t}\n\n\tvisibleViewIDs := strings.TrimSpace(node.IALAttr(av.NodeAttrVisibleViewIDs))\n\tif \"\" == visibleViewIDs {\n\t\treturn\n\t}\n\tvisibleViewCount := 0\n\tfor _, visibleViewID := range strings.Split(visibleViewIDs, \",\") {\n\t\tvisibleViewID = strings.TrimSpace(visibleViewID)\n\t\tif \"\" == visibleViewID {\n\t\t\tcontinue\n\t\t}\n\t\tvisibleViewCount++\n\t\tif nil == attrView.GetView(visibleViewID) {\n\t\t\treturn nil, fmt.Errorf(\"attribute view [%s] visible view [%s] not found\", attrView.ID, visibleViewID)","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template.go#L477-L513","documentation":"validateTemplateAttributeViewNode checks that the attribute view referenced by a template node exists and that the view ID stored in the node view IAL attribute resolves. If the node names a viewID the attribute view does not contain (deleted or renamed view), this error names both the attribute view ID and the missing view ID.","triggerScenarios":"Instantiating or saving a template whose database block has a view IAL (av.NodeAttrView) pointing to a view ID that was deleted or no longer exists in the source database.","commonSituations":"Templates exported before a view was deleted in the database, hand-edited templates copying a view ID from another attribute view, or template packs produced from an older document structure.","solutions":["Re-save the template from a document whose database still contains the referenced view","Edit the template and update or remove the view attribute on the database block so the first view is used","Verify the attribute view ID exists and pick an existing view ID from it"],"exampleFix":"// before (database block IAL in template)\n{: view='20240101120000-deleted-view'}\n// after: omit view so the first view is selected\n{: id='...'}","handlingStrategy":"validation","validationCode":"viewID := strings.TrimSpace(node.IALAttr('view'))\nif viewID != '' && attrView.GetView(viewID) == nil {\n    node.RemoveIALAttr('view') // stale view; let the first view be used\n}","typeGuard":"func hasView(attrView *av.AttributeView, viewID string) bool {\n    return attrView.GetView(strings.TrimSpace(viewID)) != nil\n}","tryCatchPattern":"selectedView, err := validateTemplateAttributeViewNode(node, attrView)\nif err != nil {\n    return fmt.Errorf('template database is stale: %w', err)\n}","preventionTips":["Regenerate templates after modifying or deleting database views","Avoid copying database blocks between templates with mismatched view IDs","Prefer omitting the view attribute so the first view is always a safe fallback"],"tags":["go","attribute-view","template","reference"],"backgroundTag":"resource-not-found","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}