From 746e8487d250d77d91dabd8463f869a3e96d0fc2 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Thu, 22 Dec 2022 16:09:06 +0100 Subject: [PATCH] fix: Issue with credentials and workflows not being matched correctly due to incorrect typing (#5011) * fix: Always return ids as strings --- packages/cli/src/credentials/credentials.controller.ee.ts | 8 +++++++- packages/cli/src/credentials/credentials.controller.ts | 4 ---- packages/cli/src/workflows/workflows.controller.ee.ts | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/credentials/credentials.controller.ee.ts b/packages/cli/src/credentials/credentials.controller.ee.ts index 1a8fccb52a..e27f30767b 100644 --- a/packages/cli/src/credentials/credentials.controller.ee.ts +++ b/packages/cli/src/credentials/credentials.controller.ee.ts @@ -35,7 +35,13 @@ EECredentialsController.get( }); // eslint-disable-next-line @typescript-eslint/unbound-method - return allCredentials.map(EECredentials.addOwnerAndSharings); + return allCredentials + .map((credential: CredentialsEntity & CredentialWithSharings) => + EECredentials.addOwnerAndSharings(credential), + ) + .map( + (credential): CredentialWithSharings => ({ ...credential, id: credential.id.toString() }), + ); } catch (error) { LoggerProxy.error('Request to list credentials failed', error as Error); throw error; diff --git a/packages/cli/src/credentials/credentials.controller.ts b/packages/cli/src/credentials/credentials.controller.ts index e5fe827507..3b1126aef7 100644 --- a/packages/cli/src/credentials/credentials.controller.ts +++ b/packages/cli/src/credentials/credentials.controller.ts @@ -3,12 +3,9 @@ import express from 'express'; import { deepCopy, - ICredentialType, INodeCredentialTestResult, LoggerProxy, - NodeHelpers, } from 'n8n-workflow'; -import { Credentials } from 'n8n-core'; import * as GenericHelpers from '@/GenericHelpers'; import { InternalHooksManager } from '@/InternalHooksManager'; @@ -17,7 +14,6 @@ import config from '@/config'; import { getLogger } from '@/Logger'; import { EECredentialsController } from './credentials.controller.ee'; import { CredentialsService } from './credentials.service'; -import { CredentialTypes } from '@/CredentialTypes'; import type { ICredentialsResponse } from '@/Interfaces'; import type { CredentialRequest } from '@/requests'; diff --git a/packages/cli/src/workflows/workflows.controller.ee.ts b/packages/cli/src/workflows/workflows.controller.ee.ts index 292cc38453..c32aec1db4 100644 --- a/packages/cli/src/workflows/workflows.controller.ee.ts +++ b/packages/cli/src/workflows/workflows.controller.ee.ts @@ -108,7 +108,7 @@ EEWorkflowController.get( EEWorkflows.addOwnerAndSharings(workflow); await EEWorkflows.addCredentialsToWorkflow(workflow, req.user); - return workflow; + return { ...workflow, id: workflow.id.toString() }; }), ); @@ -214,7 +214,7 @@ EEWorkflowController.get( EEWorkflows.addOwnerAndSharings(workflow); await EEWorkflows.addCredentialsToWorkflow(workflow, req.user); workflow.nodes = []; - return workflow; + return { ...workflow, id: workflow.id.toString() }; }), ); }),