siyuan-note/siyuan · error

Conf.Language(26)

Error message

Conf.Language(26)

What it means

GetRepoFile returns the localized Conf.Language(26) message (repo key not set) when the data repository encryption key is not configured (Conf.Repo.Key is empty). Snapshots in SiYuan's repo are encrypted, so reading any repo file by ID requires a repository key. No actual decryption is attempted when this fires.

Solutions

  1. Set up the data repo key in Settings - About - Data repo key (or import the existing key via the key string)
  2. If restoring on a new device, import the same repo key used by the original workspace
  3. Create at least one snapshot (InitRepoKey happens automatically on first sync/backup) before calling repo file APIs
  4. Check Conf.Repo.Key length client-side before invoking the API

Example fix

// before
POST /api/repo/getRepoFile {"id": "..."}  // no repo key configured
// after: initialize the repo key first
POST /api/repo/initRepoKey   // or import key, then retry getRepoFile
Defensive patterns

Strategy: validation

Validate before calling

// client-side pre-check before calling getRepoFile
const conf = await fetchPost("/api/conf/getConf", {});
if (!conf.data.repo.key || conf.data.repo.key.length === 0) {
  throw new Error("repo key not configured; run /api/repo/initRepoKey first");
}

Try / catch

data, p, err := model.GetRepoFile(fileID)
if err != nil {
    if err.Error() == model.Conf.Language(26) {
        return fmt.Errorf("repo key not configured: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling GetRepoFile(fileID) (API /api/repo/getRepoFile, used by repoFileGet) on a workspace where the repo key was never created — i.e. cloud sync / snapshots were never set up or the key was purged.

Common situations: Fresh workspace where snapshots were never initialized; user cleared the repo key from settings; workspace copied to another machine without importing the repo key; automated scripts hitting the repo API before any snapshot was taken.

Related errors


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

Appendix: source

Thrown at kernel/model/repository.go:204

		}
		purgeCancelMu.Unlock()
	}()

	_, err = repo.Purge(cancelCtx, retentionIndexIDs...)
}

func cancelPurge() {
	purgeCancelMu.Lock()
	defer purgeCancelMu.Unlock()
	if nil != purgeCancel {
		purgeCancel()
		purgeCancel = nil
	}
}

func GetRepoFile(fileID string) (ret []byte, p string, err error) {
	if 1 > len(Conf.Repo.Key) {
		err = errors.New(Conf.Language(26))
		return
	}

	ret, file, err := readRepoFileWithAssets(fileID)
	if err != nil {
		return
	}
	ret, err = decryptRepoDataIfNeeded(ret, file.Path)
	p = file.Path
	return
}

// ResolveRepoFileBoxID 返回仓库文件路径中明确记录的加密笔记本 ID。
func ResolveRepoFileBoxID(fileID string) (boxID string, err error) {
	if 1 > len(Conf.Repo.Key) {
		return "", errors.New(Conf.Language(26))
	}
	repo, err := newRepository()

View on GitHub (pinned to 9f775e8a12)