mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Handle possibly invalid updatedAt
timestamps in source-control (#8485)
This commit is contained in:
parent
2aed788dc3
commit
033fd344b5
|
@ -8,7 +8,7 @@ import {
|
||||||
SOURCE_CONTROL_WORKFLOW_EXPORT_FOLDER,
|
SOURCE_CONTROL_WORKFLOW_EXPORT_FOLDER,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
import glob from 'fast-glob';
|
import glob from 'fast-glob';
|
||||||
import { ApplicationError, jsonParse } from 'n8n-workflow';
|
import { ApplicationError, jsonParse, ErrorReporterProxy as ErrorReporter } from 'n8n-workflow';
|
||||||
import { readFile as fsReadFile } from 'fs/promises';
|
import { readFile as fsReadFile } from 'fs/promises';
|
||||||
import { Credentials, InstanceSettings } from 'n8n-core';
|
import { Credentials, InstanceSettings } from 'n8n-core';
|
||||||
import type { IWorkflowToImport } from '@/Interfaces';
|
import type { IWorkflowToImport } from '@/Interfaces';
|
||||||
|
@ -87,14 +87,28 @@ export class SourceControlImportService {
|
||||||
const localWorkflows = await Container.get(WorkflowRepository).find({
|
const localWorkflows = await Container.get(WorkflowRepository).find({
|
||||||
select: ['id', 'name', 'versionId', 'updatedAt'],
|
select: ['id', 'name', 'versionId', 'updatedAt'],
|
||||||
});
|
});
|
||||||
return localWorkflows.map((local) => ({
|
return localWorkflows.map((local) => {
|
||||||
id: local.id,
|
let updatedAt: Date;
|
||||||
versionId: local.versionId,
|
if (local.updatedAt instanceof Date) {
|
||||||
name: local.name,
|
updatedAt = local.updatedAt;
|
||||||
localId: local.id,
|
} else {
|
||||||
filename: getWorkflowExportPath(local.id, this.workflowExportFolder),
|
ErrorReporter.warn('updatedAt is not a Date', {
|
||||||
updatedAt: local.updatedAt.toISOString(),
|
extra: {
|
||||||
})) as SourceControlWorkflowVersionId[];
|
type: typeof local.updatedAt,
|
||||||
|
value: local.updatedAt,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
updatedAt = isNaN(Date.parse(local.updatedAt)) ? new Date() : new Date(local.updatedAt);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: local.id,
|
||||||
|
versionId: local.versionId,
|
||||||
|
name: local.name,
|
||||||
|
localId: local.id,
|
||||||
|
filename: getWorkflowExportPath(local.id, this.workflowExportFolder),
|
||||||
|
updatedAt: updatedAt.toISOString(),
|
||||||
|
};
|
||||||
|
}) as SourceControlWorkflowVersionId[];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getRemoteCredentialsFromFiles(): Promise<
|
public async getRemoteCredentialsFromFiles(): Promise<
|
||||||
|
|
Loading…
Reference in a new issue