siyuan-note/siyuan · error

remove legacy AI editor actions failed

Error message

remove legacy AI editor actions failed: %w

What it means

After successfully migrating legacy AI editor actions, the kernel deletes the legacy local-storage key via RemoveLocalStorageVals. This error wraps a failure of that removal, meaning migration data would linger and potentially re-run; the caller's get/save/remove operation returns the error even though the migration itself already succeeded and was saved.

Solutions

  1. Check that the workspace data directory and local-storage files are writable and not locked, then retry
  2. Close other SiYuan instances or file-sync tools holding the workspace and retry the operation
  3. If removal keeps failing, manually delete the legacy key from workspace storage after backing it up
  4. Free disk space if the volume is full
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure workspace storage is writable before API calls
await fs.access(workspaceDir, fs.constants.W_OK);

Try / catch

try {
  await getAIEditorActions();
} catch (e) {
  if (String(e).includes("remove legacy AI editor actions failed")) {
    // check disk space/locks on workspace storage, then retry; migration data already saved
  }
}

Prevention

When it happens

Trigger: Calling GetAIEditorActions, SaveAIEditorAction, or RemoveAIEditorAction during legacy migration when the underlying local-storage delete fails (storage backend unavailable, file lock or write error on the workspace storage).

Common situations: Workspace directory on a read-only or full disk; antivirus or sync tool locking the storage files; concurrent SiYuan instances writing the same workspace storage.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/ai_editor.go:262

		}
		data.Actions = append(data.Actions, &AIEditorAction{
			ID:     ast.NewNodeID(),
			Name:   legacyAction.Name,
			Action: legacyAction.Memo,
		})
		existing[key] = struct{}{}
		changed = true
	}
	if !persist {
		return nil
	}
	if changed {
		if err = saveAIEditorActions(data); err != nil {
			return err
		}
	}
	if err = RemoveLocalStorageVals([]string{legacyAIEditorActionsStorageKey}); err != nil {
		return fmt.Errorf("remove legacy AI editor actions failed: %w", err)
	}
	return nil
}

View on GitHub (pinned to 9f775e8a12)