siyuan-note/siyuan · error

26

26

Error message

Conf.Language(26)

What it means

readRepoFileWithAssets refuses to operate when no data repo key is configured (Conf.Repo == nil or Conf.Repo.Key is empty). Error i18n code 26 instructs the user to initialize the data repo key in Settings - Account & Sync - Local Data Repo - Data repo key. The repo key is required to create the repository instance and decrypt snapshot data, so reads are impossible without it.

Solutions

  1. Initialize the data repo key via Settings - Account & Sync - Local Data Repo - Data repo key (set a passphrase to generate the key)
  2. If the workspace previously had a key, restore the original conf.json — a new key cannot decrypt existing snapshots
  3. Check that Conf.Repo persisted correctly after restart; investigate config write failures if it was set but is gone after boot

Example fix

// before: calling the API unconditionally
data, err := model.GetRepoFile(fileID)
// after: guard on repo key presence
if model.Conf.Repo == nil || len(model.Conf.Repo.Key) == 0 {
    return errors.New(model.Conf.Language(26))
}
data, err := model.GetRepoFile(fileID)
Defensive patterns

Strategy: validation

Validate before calling

if model.Conf.Repo == nil || len(model.Conf.Repo.Key) == 0 {
    return errors.New(model.Conf.Language(26))
}

Try / catch

data, err := model.GetRepoFile(fileID)
if err != nil && strings.Contains(err.Error(), model.Conf.Language(26)) {
    return errRepoKeyUninitialized
}

Prevention

When it happens

Trigger: Any caller of readRepoFileWithAssets (GetRepoFile, RollbackRepoSnapshotFile, OpenRepoSnapshotFile, ExportRepoFile, tests) executed on a workspace where the local data repo key was never initialized — e.g. sync never set up, or Conf.Repo wiped by config reset/migration.

Common situations: Fresh workspace or restored data directory without conf.json repo section; user cleared the repo key; automated scripts calling repo-file APIs on an uninitialized workspace.

Related errors


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

Appendix: source

Thrown at kernel/model/asset_download.go:374

		return data, err
	}
	if err = checkAssetDownloadAccess(); err != nil {
		return nil, err
	}
	handleCloudError := cloudRepoErrorHandler()
	if err = repo.EnsureFileChunks(file, newSyncContext()); err != nil {
		handleCloudError(err)
		return nil, fmt.Errorf("%s: %w", Conf.Language(376), err)
	}
	return repo.OpenFile(file)
}

// readRepoFileWithAssets 将仓库实例的创建和历史分块补齐纳入来源读锁。
func readRepoFileWithAssets(fileID string) ([]byte, *entity.File, error) {
	assetDownloadSourceMu.RLock()
	defer assetDownloadSourceMu.RUnlock()
	if Conf.Repo == nil || len(Conf.Repo.Key) == 0 {
		return nil, nil, errors.New(Conf.Language(26))
	}
	repo, err := newRepositoryWithAssetSourceLocked()
	if err != nil {
		return nil, nil, err
	}
	file, err := repo.GetFile(fileID)
	if err != nil {
		return nil, nil, err
	}
	if boxID := encryptedBoxIDFromRepoPath(file.Path); boxID != "" && !IsBoxUnlocked(boxID) {
		return nil, nil, errors.New(Conf.Language(314))
	}
	data, err := openRepoFileWithAssets(repo, file)
	return data, file, err
}

func ensureRepoSnapshotComplete(repo *dejavu.Repo, indexID string) error {
	index, err := repo.GetIndex(indexID)

View on GitHub (pinned to 9f775e8a12)