{"record":{"id":"a6c5e2eb88283f3c","repo":"siyuan-note/siyuan","slug":"parse-attribute-view-s-in-box-s-failed-w","errorCode":null,"errorMessage":"parse attribute view [%s] in box [%s] failed: %w","messagePattern":"parse attribute view \\[(.+?)\\] in box \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template.go","lineNumber":572,"sourceCode":"\tcopySources := map[string]*av.AttributeView{}\n\tcopyBySourceID := map[string]*templateAttributeViewCopy{}\n\tboxID := templateAttributeViewBoxID(tree)\n\tast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {\n\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}","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template.go#L554-L590","documentation":"When a template embeds a database in reference mode, the kernel must load the referenced attribute view from the notebook (box) via av.ParseAttributeViewInBox. This error wraps the underlying parse failure (I/O, JSON decode, lock error) with the attribute view ID and box ID for diagnosis.","triggerScenarios":"Rendering a template whose database node references attribute view ID X in box B, and ParseAttributeViewInBox fails (missing/unreadable .av file, JSON corruption, file lock timeout).","commonSituations":"Template referencing a database that was deleted or whose storage file was removed by an incomplete sync; encrypted-box key issues preventing read; disk permission problems.","solutions":["Check that the referenced attribute view still exists under the box's storage (data/storage/av/<id>.av) and is valid JSON","Remove the stale database node from the template or update its AttributeViewID to an existing database","Check kernel logs (the wrapped %w cause) for the underlying I/O or lock error and fix that first (permissions, disk space, sync conflicts)"],"exampleFix":"// before: template references a deleted database id\n{{database id=\"20240101120000-abcdefg\"}}\n// after: point the node at an existing attribute view\n{{database id=\"20240101120000-existing\"}}","handlingStrategy":"try-catch","validationCode":"// verify the referenced database file exists before rendering\nif _, statErr := os.Stat(filepath.Join(boxStorageDir, \"av\", avID+\".av\")); statErr != nil {\n    return fmt.Errorf(\"referenced attribute view %s missing\", avID)\n}","typeGuard":null,"tryCatchPattern":"if _, err := av.ParseAttributeViewInBox(avID, boxID); err != nil {\n    logging.LogErrorf(\"cannot resolve referenced av %s in box %s: %v\", avID, boxID, err)\n    // fall back to copy mode or skip the node\n}","preventionTips":["Reference databases only within the same notebook (box)","Check kernel logs for the wrapped underlying cause","Keep sync conflicts resolved so .av files are not lost"],"tags":["go","attribute-view","file-read","parse"],"backgroundTag":"file-read-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}