fix(core): Prevent workflow history saving error from happening (#7812)

When performing actions such as renaming a workflow or updating its
settings, n8n errors with "Failed to save workflow version" in the
console although the saving process was successful. We are now correctly
checking whether `nodes` and `connections` exist and only then save a
snapshot.

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Omar Ajoue
2023-12-13 11:41:06 +00:00
committed by GitHub
parent b00b9057a4
commit e5581ce802
6 changed files with 290 additions and 158 deletions

View File

@@ -66,7 +66,10 @@ export class WorkflowHistoryService {
}
async saveVersion(user: User, workflow: WorkflowEntity, workflowId: string) {
if (isWorkflowHistoryEnabled()) {
// On some update scenarios, `nodes` and `connections` are missing, such as when
// changing workflow settings or renaming. In these cases, we don't want to save
// a new version
if (isWorkflowHistoryEnabled() && workflow.nodes && workflow.connections) {
try {
await this.workflowHistoryRepository.insert({
authors: user.firstName + ' ' + user.lastName,