siyuan-note/siyuan · error

Conf.Language(26)

Error message

Conf.Language(26)

What it means

readRepoFileWithAssets refuses to read any repository file when Conf.Repo is nil or Conf.Repo.Key is empty, returning the localized message Conf.Language(26) (roughly 'repo key not initialized'). The repo encryption key is required to construct the repository instance and decrypt chunks; without it no repo file can be opened.

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 8641553a1f)

Solutions

  1. Enable cloud sync in Settings - About - Cloud (or run InitRepoKey) so Conf.Repo and its key are generated
  2. If the key was lost, recover it from another synced device via Settings - About - Cloud - Repo Key copy/paste
  3. Verify conf.json in the workspace contains the repo section with a non-empty Key
  4. Only call these repo-read APIs after confirming the repo is initialized (e.g. via the /api/repo/getRepoKeyexists endpoint)

Example fix

// before
data, err := model.GetRepoFile(fileID) // 'repo key not set'
// after
if exist, _ := model.GetRepoKeyExists(); !exist {
    return errors.New("repo key not initialized; enable cloud sync first")
}
data, err := model.GetRepoFile(fileID)
Defensive patterns

Strategy: validation

Validate before calling

if conf.Conf.Repo == nil || len(conf.Conf.Repo.Key) == 0 {
    return errors.New("repo key missing: enable cloud sync or copy the key from another device")
}

Try / catch

data, err := model.GetRepoFile(fileID)
if err != nil && strings.Contains(err.Error(), conf.Conf.Language(26)) {
    return fmt.Errorf("call InitRepoKey / enable cloud sync first: %w", err)
}

Prevention

When it happens

Trigger: Any call to GetRepoFile, RollbackRepoSnapshotFile, OpenRepoSnapshotFile, or ExportRepoFile on a workspace where cloud sync/snapshot has never been configured, or where Conf.Repo.Key was lost (fresh clone, corrupted conf.json, switching workspaces).

Common situations: User tries to browse snapshot history on a brand-new workspace that never enabled cloud sync; config file was reset or migrated without carrying over the repo key; automated scripts call the repo APIs before initRepoKey ran.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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