siyuan-note/siyuan · error

314

314

Error message

Conf.Language(314)

What it means

After locating the repo file, readRepoFileWithAssets checks whether the file's path belongs to an encrypted notebook (encryptedBoxIDFromRepoPath) and, if that notebook is currently locked, aborts with i18n message 314 ('Please unlock the encrypted notebook first'). Encrypted notebooks must be unlocked so their keys are in memory before any snapshot content can be legitimately read.

Solutions

  1. Unlock the encrypted notebook (enter its passphrase) and retry the read/export
  2. Unlock programmatically via the box unlock API before calling repo-file APIs in scripts
  3. Route the request through the UI, which prompts for unlock instead of failing
  4. Verify with IsBoxUnlocked(boxID) before issuing the call

Example fix

// before
data, err := model.GetRepoFile(fileID)
// after
if boxID := model.BoxIDOfRepoFile(fileID); boxID != "" && !model.IsBoxUnlocked(boxID) {
    return errors.New(model.Conf.Language(314)) // prompt user to unlock
}
data, err := model.GetRepoFile(fileID)
Defensive patterns

Strategy: validation

Validate before calling

if boxID != "" && model.IsEncryptedBox(boxID) && !model.IsBoxUnlocked(boxID) {
    return errors.New(model.Conf.Language(314))
}

Try / catch

data, err := model.GetRepoFile(fileID)
var unlockErr *model.EncryptedBoxLockedError
if errors.As(err, &unlockErr) {
    promptUserToUnlock(unlockErr.BoxID)
}

Prevention

When it happens

Trigger: GetRepoFile / OpenRepoSnapshotFile / RollbackRepoSnapshotFile / ExportRepoFile / TestAssetDownloadModePreservesHistoricalRecovery reading a file whose repo path maps to an encrypted box while the box is locked (user has not entered the notebook passphrase since kernel start, or locked it manually).

Common situations: Accessing history/versions of an encrypted notebook after kernel restart (lock state is not persisted); automated export scripts running without the notebook unlocked; user locked the encrypted notebook and then tried to view an old asset or snapshot.

Related errors


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

Appendix: source

Thrown at kernel/model/asset_download.go:385

}

// 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)
	if err != nil {
		return err
	}
	return repo.GetFilesIter(index, func(file *entity.File) error {
		if !repoFileNeedsDownload(file) {
			return nil
		}
		if err := checkAssetDownloadAccess(); err != nil {
			return err
		}
		handleCloudError := cloudRepoErrorHandler()

View on GitHub (pinned to 9f775e8a12)