{"record":{"id":"8cf20e638ddd5a05","repo":"siyuan-note/siyuan","slug":"attribute-view-s-not-found-in-box-s","errorCode":null,"errorMessage":"attribute view [%s] not found in box [%s]","messagePattern":"attribute view \\[(.+?)\\] not found in box \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template.go","lineNumber":660,"sourceCode":"\t\tif !entering || ast.NodeAttributeView != n.Type {\n\t\t\treturn ast.WalkContinue\n\t\t}\n\n\t\tmode, modeErr := templateAttributeViewMode(n)\n\t\tif nil != modeErr {\n\t\t\terr = modeErr\n\t\t\treturn ast.WalkStop\n\t\t}\n\t\tif TemplateDatabaseModeReference == mode {\n\t\t\tsource := referenceSources[n.AttributeViewID]\n\t\t\tif nil == source {\n\t\t\t\tsource, modeErr = av.ParseAttributeViewInBox(n.AttributeViewID, boxID)\n\t\t\t\tif nil != modeErr {\n\t\t\t\t\terr = fmt.Errorf(\"parse attribute view [%s] in box [%s] failed: %w\", n.AttributeViewID, boxID, modeErr)\n\t\t\t\t\treturn ast.WalkStop\n\t\t\t\t}\n\t\t\t\tif nil == source || source.ID != n.AttributeViewID {\n\t\t\t\t\terr = fmt.Errorf(\"attribute view [%s] not found in box [%s]\", n.AttributeViewID, boxID)\n\t\t\t\t\treturn ast.WalkStop\n\t\t\t\t}\n\t\t\t\treferenceSources[n.AttributeViewID] = source\n\t\t\t}\n\t\t\tselectedView, validateErr := validateTemplateAttributeViewNode(n, source)\n\t\t\tif nil != validateErr {\n\t\t\t\terr = validateErr\n\t\t\t\treturn ast.WalkStop\n\t\t\t}\n\t\t\tplans[n] = &templateAttributeViewPlan{\n\t\t\t\tmode: mode, source: source, target: source, selectedView: selectedView,\n\t\t\t}\n\t\t\treturn ast.WalkContinue\n\t\t}\n\n\t\tsource := copySources[n.AttributeViewID]\n\t\tif nil == source {\n\t\t\tsource, modeErr = av.ParseAttributeView(n.AttributeViewID)","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template.go#L642-L678","documentation":"When rendering a template that contains a database (attribute view) block in reference mode, the kernel tries to load the referenced attribute view from the notebook (box) derived from the template source tree. If ParseAttributeViewInBox returns nothing or an attribute view whose ID does not match the node's AttributeViewID, the walk stops with this error. It guards against stale or dangling database references inside templates.","triggerScenarios":"Rendering a template (RenderTemplateWithMode / PreviewTemplateSource) whose tree contains an ast.NodeAttributeView with a 'custom-av' style reference mode whose AttributeViewID does not exist under the template's box, e.g. the .av file was deleted, the ID was copy-pasted from another notebook, or the box ID is wrong.","commonSituations":"A template was shared/exported between notebooks without the referenced database; a user deleted the database but kept the template block; the database ID in the template was hand-edited; sync conflicts left the block pointing at a removed attribute view file.","solutions":["Verify the attribute view ID in the template block's custom attribute (custom-av) exists in the template's notebook (storage/av/ under the box).","Remove or fix the stale database block in the template, or recreate the referenced database and update the ID.","If the reference is intended cross-notebook, move the template into the box that actually contains the attribute view."],"exampleFix":"// before (template block IAL)\n{: custom-av id=\"20240101120000-abcdefg\"}\n// after: point at an existing av in this box, or switch the block to copy mode\n{: custom-av id=\"20240501100000-xyz1234\" type=\"NodeAttributeView\"}","handlingStrategy":"validation","validationCode":"// Go caller: check the av exists in the box before rendering\nif _, err := os.Stat(filepath.Join(workspace, \"data\", boxID, \".siyuan\", \"storage\", \"av\", avID+\".json\")); err != nil {\n    return fmt.Errorf(\"attribute view %s missing in box %s\", avID, boxID)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"not found in box\") {\n        // recreate or remove the stale database block\n        return recoverStaleAvReference(avID, boxID)\n    }\n    return err\n}","preventionTips":["Keep templates in the same notebook as the databases they reference","When sharing templates, export referenced databases together","Periodically audit custom-av IDs in templates against existing .av files"],"tags":["go","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"}