siyuan-note/siyuan · error

attribute view snapshot context is ambiguous

Error message

attribute view snapshot context is ambiguous [%s]

What it means

ResolveRepoSnapshotAttributeViewBoxID searches repo snapshots for the attribute view file matching avID. Exactly one match is required to unambiguously determine the owning notebook (box) ID; when multiple snapshot paths contain the same avID, the context is ambiguous and this error is returned instead of guessing.

Solutions

  1. Locate and remove/rename the duplicate attribute view file so only one snapshot path contains avID
  2. Search the repo index for the avID across notebooks to identify which duplicate is stale
  3. If duplicates are intentional, resolve at a higher level by passing explicit notebook context instead of relying on auto-resolution

Example fix

// before
boxID, err := model.ResolveRepoSnapshotAttributeViewBoxID(avID) // ambiguous
// after
// deduplicate first, or pass explicit boxID:
boxID, err := explicitBoxID, nil
Defensive patterns

Strategy: try-catch

Validate before calling

matches := globRepoPaths(avID)
if len(matches) == 0 { return ErrNotFound }
if len(matches) > 1 { return ErrAmbiguous }

Type guard

func hasUniqueSnapshotMatch(matches []match) bool { return len(matches) == 1 }

Try / catch

boxID, err := model.ResolveRepoSnapshotAttributeViewBoxID(avID)
if err != nil && strings.Contains(err.Error(), "snapshot context is ambiguous") {
    return promptUserToPickNotebook(avID)
}

Prevention

When it happens

Trigger: The same attribute view file (same avID) exists in more than one notebook's snapshot path in the repository — e.g. the .av file was duplicated or copied between notebooks before snapshotting.

Common situations: Manually copying documents between notebooks causing duplicate av files; sync conflicts leaving the same attribute view in multiple boxes; restoring snapshots creating duplicates.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/bba0caa3915f9daf. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/attribute_view_render.go:1215

	index, err := repo.GetIndex(indexID)
	if err != nil {
		return "", err
	}
	files, err := repo.GetFiles(index)
	if err != nil {
		return "", err
	}
	var matches []*entity.File
	for _, file := range files {
		if strings.HasSuffix(file.Path, "/storage/av/"+avID+".json") {
			matches = append(matches, file)
		}
	}
	if len(matches) == 0 {
		return "", av.ErrAttributeViewNotFound
	}
	if len(matches) != 1 {
		return "", fmt.Errorf("attribute view snapshot context is ambiguous [%s]", avID)
	}
	boxID := avBoxIDFromRepoPath(matches[0].Path)
	if IsEncryptedBox(boxID) {
		return boxID, nil
	}
	return "", nil
}

// ResolveHistoryAttributeViewBoxID 返回历史属性视图的唯一加密笔记本上下文。
func ResolveHistoryAttributeViewBoxID(avID, created string) (string, error) {
	if !ast.IsNodeIDPattern(avID) {
		return "", ErrInvalidID
	}
	createdUnix, err := strconv.ParseInt(created, 10, 64)
	if err != nil {
		return "", fmt.Errorf("parse created [%s] failed: %w", created, err)
	}
	dirPrefix := time.Unix(createdUnix, 0).Format("2006-01-02-150405")

View on GitHub (pinned to 9f775e8a12)