siyuan-note/siyuan · error

CLI does not support encrypted notebook history

Error message

CLI does not support encrypted notebook history

What it means

`history get` and `history rollback` accept a --path pointing at history files; the CLI cleans the path (resolving relative paths against util.WorkspaceDir) and checks model.IsEncryptedHistoryPath. History belonging to encrypted notebooks is outside the CLI's scope — it can only be accessed through the in-app unlock flow — so the command aborts.

Solutions

  1. Restore history for that notebook via the SiYuan app's history UI instead of the CLI.
  2. Check the --path value; only use history paths of non-encrypted notebooks.
  3. Exclude encrypted-notebook history entries from automation that drives history rollback.

Example fix

// before
SiYuan-Kernel history rollback --path "history/20240101120000-enc1/..."
// after: use the in-app history panel, or target a plain notebook
SiYuan-Kernel history rollback --path "history/20240101120000-plain/..."
Defensive patterns

Strategy: validation

Validate before calling

// Go: pre-check history paths against the encrypted-history matcher
if model.IsEncryptedHistoryPath(filepath.Clean(p)) { return skip }

Try / catch

if err := runKernelCLI(args); err != nil && strings.Contains(err.Error(), "encrypted notebook history") {
    // perform the rollback in the app's history panel instead
}

Prevention

When it happens

Trigger: Running `SiYuan-Kernel history get` or `history rollback` with --path resolving to a history path of an encrypted notebook (e.g. under the workspace's history directory for an encrypted box), whether passed as a relative or absolute path.

Common situations: Rollback scripts iterating history entries without distinguishing encrypted notebooks; restoring an older snapshot whose source notebook was encrypted; pointing history rollback at a history directory by hand.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at kernel/cli/cmd/root.go:200

	if cmd.Parent() == assetCmd {
		if pathFlag := cmd.Flags().Lookup("path"); pathFlag != nil && pathFlag.Value.String() != "" {
			assetPath := pathFlag.Value.String()
			if !filepath.IsAbs(assetPath) {
				assetPath = filepath.Join("data", assetPath)
			}
			if isEncryptedNotebookWorkspacePath(assetPath) {
				return fmt.Errorf("CLI does not support files in encrypted notebooks")
			}
		}
	}
	if cmd == historyGetCmd || cmd == historyRollbackCmd {
		historyPath, _ := cmd.Flags().GetString("path")
		if historyPath != "" {
			if !filepath.IsAbs(historyPath) {
				historyPath = filepath.Join(util.WorkspaceDir, historyPath)
			}
			if model.IsEncryptedHistoryPath(filepath.Clean(historyPath)) {
				return fmt.Errorf("CLI does not support encrypted notebook history")
			}
		}
	}
	if cmd.Parent() == repoFileCmd {
		fileID, _ := cmd.Flags().GetString("id")
		if fileID != "" {
			boxID, err := model.ResolveRepoFileBoxID(fileID)
			if err != nil {
				return err
			}
			if boxID != "" {
				return fmt.Errorf("CLI does not support encrypted notebook [%s]", boxID)
			}
		}
	}
	return nil
}

View on GitHub (pinned to 9f775e8a12)