siyuan-note/siyuan · error

attribute view snapshot context is ambiguous [%s]

Error message

attribute view snapshot context is ambiguous [%s]

What it means

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.

Source

Thrown at kernel/model/history_diff.go:552

		if nil != indexErr {
			return nil, indexErr
		}
		files, filesErr := repo.GetFiles(index)
		if nil != filesErr {
			return nil, filesErr
		}
		readData = func(id string) ([]byte, error) {
			var matchingFiles []*entity.File
			for _, file := range files {
				if strings.HasSuffix(filepath.ToSlash(file.Path), "/storage/av/"+id+".json") {
					matchingFiles = append(matchingFiles, file)
				}
			}
			if len(matchingFiles) == 0 {
				return nil, nil
			}
			if len(matchingFiles) != 1 {
				return nil, fmt.Errorf("attribute view snapshot context is ambiguous [%s]", id)
			}
			file := matchingFiles[0]
			data, readErr := repo.OpenFile(file)
			if nil != readErr {
				return nil, readErr
			}
			return decryptHistoricalAttributeView(avBoxIDFromRepoPath(file.Path), id, data)
		}
	}
	if nil == readData {
		return
	}

	for id := range ids {
		data, readErr := readData(id)
		if nil != readErr {
			return nil, readErr
		}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Inspect the snapshot index (repo.GetFiles output) for duplicate /storage/av/<id>.json paths and remove the corrupted snapshot
  2. Rebuild or re-sync the affected snapshot: create a fresh snapshot and retry the diff
  3. Verify repo data integrity (checksums) and restore the affected snapshot from a known-good backup
  4. Report it as a bug with the snapshot ID and attribute-view ID if duplicates appear in a normally synced repo

Example fix

// before
if len(matchingFiles) != 1 {
    return nil, fmt.Errorf("attribute view snapshot context is ambiguous [%s]", id)
}
// after
// caller side: skip unreadable AVs in history rendering instead of failing the whole diff
data, readErr := readData(id)
if readErr != nil {
    logging.LogWarnf("skip ambiguous attribute view history [%s]: %s", id, readErr)
    continue
}
Defensive patterns

Strategy: try-catch

Try / catch

// Go caller
data, err := readData(avID)
if err != nil {
    if strings.HasPrefix(err.Error(), "attribute view snapshot context is ambiguous") {
        logging.LogWarnf("skipping ambiguous AV history [%s]", avID)
        return nil, nil
    }
    return nil, err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/f0e7d89af045e08b. Report an issue: GitHub.