siyuan-note/siyuan · error

26

26

Error message

Please initialize the data repo key first in [Settings - Account & Sync - Local Data Repo - Data repo key]

What it means

Returned by loadSnapshotDocVersion (history_diff.go:402) as Conf.Language(26) = "Please initialize the data repo key first in [Settings - Account & Sync - Local Data Repo - Data repo key]". Snapshots are stored in the dejavu data repo which is encrypted with Conf.Repo.Key; if that key is uninitialized (len < 1), no repo object can be opened. The guard fires before newRepository so the user gets a setup hint instead of a repo-open error.

Source

Thrown at kernel/model/history_diff.go:402

		}, nil
	}
	return &loadedDocVersion{
		tree:    tree,
		title:   tree.Root.IALAttr("title"),
		rootID:  tree.Root.ID,
		raw:     data,
		large:   1024*1024 <= len(data),
		boxID:   boxID,
		history: historyRoot,
	}, nil
}

func loadSnapshotDocVersion(fileID string) (ret *loadedDocVersion, err error) {
	if "" == fileID {
		return nil, errors.New("snapshot file ID is required")
	}
	if 1 > len(Conf.Repo.Key) {
		return nil, errors.New(Conf.Language(26))
	}
	repo, err := newRepository()
	if err != nil {
		return nil, err
	}
	file, err := repo.GetFile(fileID)
	if err != nil {
		return nil, err
	}
	if !strings.HasSuffix(strings.ToLower(file.Path), ".sy") {
		return nil, errors.New("snapshot version is not a document")
	}
	repoPath := strings.TrimPrefix(file.Path, "/")
	pathParts := strings.SplitN(repoPath, "/", 2)
	data, err := repo.OpenFile(file)
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Initialize the data repo key at Settings - Account & Sync - Local Data Repo - Data repo key (Create/Import), then retry.
  2. If the key was created but lost, restore it from the user's backup; otherwise snapshots from the old key are unrecoverable.
  3. At the API layer, surface code 26 verbatim so the client can deep-link to the repo-key settings panel.
Defensive patterns

Strategy: validation

Validate before calling

if 1 > len(Conf.Repo.Key) {
    return errors.New(Conf.Language(26))
}
// safe to load snapshot doc version

Try / catch

diff, err := DiffDocVersions(left, right)
if err != nil && err.Error() == Conf.Language(26) {
    // route user to Settings - Account & Sync - Local Data Repo - Data repo key
}

Prevention

When it happens

Trigger: Any call to loadSnapshotDocVersion on a workspace where the data repo key has never been created; a fresh install where the user opened the diff dialog against a snapshot before completing first-time setup; a corrupted conf that lost the key.

Common situations: New workspace that has not gone through Settings - Account & Sync - Local Data Repo - Data repo key initialization; migration between machines without copying the key; a config reset.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/c5bd3b3aeb888950. Report an issue: GitHub.