{"record":{"id":"89b5efd33e2ea549","repo":"siyuan-note/siyuan","slug":"cannot-parse-attribute-view-s-v","errorCode":null,"errorMessage":"cannot parse attribute view %s: %v","messagePattern":"cannot parse attribute view (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/asset_relink.go","lineNumber":324,"sourceCode":"\t\t}\n\t\tdata, err := filelock.ReadFile(abs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif util.IsCiphertext(data) {\n\t\t\treturn fmt.Errorf(\"encrypted attribute view in global storage: %s\", id)\n\t\t}\n\t\tif !json.Valid(data) {\n\t\t\treturn fmt.Errorf(\"invalid attribute view JSON: %s\", id)\n\t\t}\n\t\tif !p.mayContainReferences(data) {\n\t\t\tcontinue\n\t\t}\n\t\tp.parsedViews++\n\t\tcache.RemoveAVData(id)\n\t\tview, err := av.ParseAttributeViewByPath(abs)\n\t\tif err != nil || view == nil || view.ID != id {\n\t\t\treturn fmt.Errorf(\"cannot parse attribute view %s: %v\", id, err)\n\t\t}\n\t\tbefore := len(p.result.References)\n\t\tif err = p.attributeView(view, apicontract.AssetReference{AvID: id, Path: \"storage/av/\" + entry.Name()}); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(p.result.References) > before {\n\t\t\tp.files = append(p.files, &assetRelinkFile{path: abs, before: data, view: view, items: p.referenceItems(before)})\n\t\t\towners := []apicontract.AssetReference{}\n\t\t\tfor _, tree := range p.trees {\n\t\t\t\tast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {\n\t\t\t\t\tif entering && n.Type == ast.NodeAttributeView && n.AttributeViewID == id {\n\t\t\t\t\t\towners = append(owners, apicontract.AssetReference{Notebook: tree.Box, RootID: tree.Root.ID, BlockID: n.ID})\n\t\t\t\t\t}\n\t\t\t\t\treturn ast.WalkContinue\n\t\t\t\t})\n\t\t\t}\n\t\t\tif len(owners) > 0 {\n\t\t\t\treferences := append([]apicontract.AssetReference(nil), p.result.References[before:]...)","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/asset_relink.go#L306-L342","documentation":"After JSON validation, scanViews parses the attribute-view definition with av.ParseAttributeViewByPath and requires the parsed view to be non-nil with an ID matching the filename. A parse failure, nil result, or ID mismatch means the definition's internal ID does not correspond to its storage filename, so the relinker stops to avoid relinking under the wrong identity.","triggerScenarios":"storage/av/<id>.json is valid JSON but has an invalid schema, or the \"id\" field inside differs from <id> (file renamed/copied under a different ID, e.g. duplicating an AV file manually).","commonSituations":"A user copied an AV .json file to a new ID to 'clone' a database without updating its internal id; schema drift after downgrading/upgrading versions; hand-edited definitions.","solutions":["Restore the original definition so the internal id matches the filename","Rename the file back to <internal-id>.json so it matches the id field","Use the app's duplicate-database feature instead of copying .json files manually","Rebuild the AV from the notebook block if the definition is unrecoverable"],"exampleFix":"// before\n// file: storage/av/20240101120000-abc123.json, content id: \"20240101120000-xyz789\"\n// after\n// rename file to match internal id\nos.Rename(\"data/storage/av/20240101120000-abc123.json\", \"data/storage/av/20240101120000-xyz789.json\")","handlingStrategy":"validation","validationCode":"// confirm the internal id matches the filename before relinking\nvar probe struct { ID string `json:\"id\"` }\njson.Unmarshal(data, &probe)\nif probe.ID != idFromFilename {\n\t// rename the file to match the internal id, or restore the original\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the app's built-in duplicate feature instead of copying .json files","Never rename storage/av files manually","Keep kernel and client versions in sync to avoid schema drift"],"tags":["attribute-view","parse-failure","id-mismatch","json"],"backgroundTag":"schema-validation-failed","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"}