{"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":579,"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":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template.go#L561-L597","documentation":"validateTemplateAttributeViewNode checks that the view ID recorded in the attribute-view node's `custom-view-id` IAL actually exists in the parsed attribute view. When av.AttributeView.GetView(viewID) returns nil, this error names both the attribute view ID and the missing view ID, and template rendering stops. It guards against template blocks pointing at views that no longer exist.","triggerScenarios":"A template block references an attribute view via `custom-av-view` (av.NodeAttrView) whose ID is not among attrView.Views: the view was deleted, the template was copied without its source database, or IDs were regenerated. Raised while rendering templates containing attribute-view nodes in reference or copy mode.","commonSituations":"Deleting a view from a database that a template still targets, sharing templates as raw .sy text without the referenced database, or renaming/regenerating view IDs with external tooling.","solutions":["Point the node's view attribute at an existing view ID in the target attribute view","Remove the view attribute so the first available view is used instead","Recreate the deleted view, or re-export the template so view IDs match the shipped database","Open the database in the UI and confirm the view exists before inserting the template"],"exampleFix":"<!-- before -->\n<div custom-av-view=\"20240101120000-deleted1\" ...></div>\n<!-- after -->\n<div ...></div>  <!-- no custom-av-view: falls back to first view -->","handlingStrategy":"validation","validationCode":"const av = await getAttrView(avID);\nif (viewID && !av.views.some(v => v.id === viewID)) {\n  // clear custom-av-view so the first view is used\n  await setBlockAttrs(blockID, {\"custom-av-view\": \"\"});\n}","typeGuard":null,"tryCatchPattern":"try {\n  await insertTemplate(path);\n} catch (e) {\n  if (String(e).includes(\"view [\").includes(\"not found\")) {\n    await stripViewAttrAndRetry(blockID, path);\n  }\n}","preventionTips":["Regenerate templates after deleting or recreating database views","Ship templates together with their referenced database so IDs stay valid","Prefer omitting the view attribute unless a specific view is required","Check view IDs via the API before inserting a template programmatically"],"tags":["attribute-view","template","not-found"],"backgroundTag":"entity-not-found","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"}