{"record":{"id":"f0e7d89af045e08b","repo":"siyuan-note/siyuan","slug":"attribute-view-snapshot-context-is-ambiguous-s-f0e7d8","errorCode":null,"errorMessage":"attribute view snapshot context is ambiguous [%s]","messagePattern":"attribute view snapshot context is ambiguous \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/history_diff.go","lineNumber":552,"sourceCode":"\t\tif nil != indexErr {\n\t\t\treturn nil, indexErr\n\t\t}\n\t\tfiles, filesErr := repo.GetFiles(index)\n\t\tif nil != filesErr {\n\t\t\treturn nil, filesErr\n\t\t}\n\t\treadData = func(id string) ([]byte, error) {\n\t\t\tvar matchingFiles []*entity.File\n\t\t\tfor _, file := range files {\n\t\t\t\tif strings.HasSuffix(filepath.ToSlash(file.Path), \"/storage/av/\"+id+\".json\") {\n\t\t\t\t\tmatchingFiles = append(matchingFiles, file)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(matchingFiles) == 0 {\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t\tif len(matchingFiles) != 1 {\n\t\t\t\treturn nil, fmt.Errorf(\"attribute view snapshot context is ambiguous [%s]\", id)\n\t\t\t}\n\t\t\tfile := matchingFiles[0]\n\t\t\tdata, readErr := repo.OpenFile(file)\n\t\t\tif nil != readErr {\n\t\t\t\treturn nil, readErr\n\t\t\t}\n\t\t\treturn decryptHistoricalAttributeView(avBoxIDFromRepoPath(file.Path), id, data)\n\t\t}\n\t}\n\tif nil == readData {\n\t\treturn\n\t}\n\n\tfor id := range ids {\n\t\tdata, readErr := readData(id)\n\t\tif nil != readErr {\n\t\t\treturn nil, readErr\n\t\t}","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/history_diff.go#L534-L570","documentation":"While diffing a document-version history snapshot, the kernel resolves historical attribute-view (.av) files by scanning the snapshot's file index for a path ending in `/storage/av/<id>.json`. This error is thrown when the same attribute-view ID matches more than one file in the snapshot index, so the correct file to decrypt is ambiguous. It indicates corrupted or inconsistently merged snapshot data rather than a caller mistake.","triggerScenarios":"Calling history/snapshot diff APIs (e.g. the history diff path that builds readData for docVersionSnapshot refs, such as CompareDoc or history rendering) where the snapshot index contains two or more files whose path ends with /storage/av/<same-id>.json for the same attribute-view ID.","commonSituations":"Corrupted or partially-merged snapshot indexes in the sync/repo store; duplicate entries produced by interrupted snapshot creation; manually copying or restoring repo data; attribute-view IDs reused across merged notebooks within one snapshot.","solutions":["Inspect the snapshot index (repo.GetFiles output) for duplicate /storage/av/<id>.json paths and remove the corrupted snapshot","Rebuild or re-sync the affected snapshot: create a fresh snapshot and retry the diff","Verify repo data integrity (checksums) and restore the affected snapshot from a known-good backup","Report it as a bug with the snapshot ID and attribute-view ID if duplicates appear in a normally synced repo"],"exampleFix":"// before\nif len(matchingFiles) != 1 {\n    return nil, fmt.Errorf(\"attribute view snapshot context is ambiguous [%s]\", id)\n}\n// after\n// caller side: skip unreadable AVs in history rendering instead of failing the whole diff\ndata, readErr := readData(id)\nif readErr != nil {\n    logging.LogWarnf(\"skip ambiguous attribute view history [%s]: %s\", id, readErr)\n    continue\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go caller\ndata, err := readData(avID)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"attribute view snapshot context is ambiguous\") {\n        logging.LogWarnf(\"skipping ambiguous AV history [%s]\", avID)\n        return nil, nil\n    }\n    return nil, err\n}","preventionTips":["Do not manually edit or merge snapshot repo data","Keep sync interruptions from producing merged snapshots — resync cleanly after conflicts","Periodically verify snapshot integrity via SiYuan's data repo check/backup features","Report duplicates in snapshot indexes as a kernel bug"],"tags":["history","snapshot","attribute-view","ambiguity","storage"],"backgroundTag":"internal-invariant-violation","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"}