From 017ae6e1025fb4ae28b46b9c411e4b5c70e280e9 Mon Sep 17 00:00:00 2001
From: Michael Kret <88898367+michael-radency@users.noreply.github.com>
Date: Wed, 24 Apr 2024 16:04:14 +0300
Subject: [PATCH] fix(Airtable Node): Do not allow to use deprecated api keys
in v1 (#9171)
---
.../credentials/AirtableApi.credentials.ts | 2 +-
.../nodes/Airtable/v1/AirtableV1.node.ts | 27 ++++++++++++++++---
.../test/nodes/Airtable/Airtable.node.test.ts | 19 +++++++------
packages/workflow/src/Interfaces.ts | 2 +-
4 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/packages/nodes-base/credentials/AirtableApi.credentials.ts b/packages/nodes-base/credentials/AirtableApi.credentials.ts
index 857ce45ea..26832901a 100644
--- a/packages/nodes-base/credentials/AirtableApi.credentials.ts
+++ b/packages/nodes-base/credentials/AirtableApi.credentials.ts
@@ -10,7 +10,7 @@ export class AirtableApi implements ICredentialType {
properties: INodeProperties[] = [
{
displayName:
- 'API Keys will be deprecated by the end of January 2024, see this article for more details. We recommend to use Personal Access Token instead.',
+ "This type of connection (API Key) was deprecated and can't be used anymore. Please create a new credential of type 'Access Token' instead.",
name: 'deprecated',
type: 'notice',
default: '',
diff --git a/packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts b/packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts
index 396db4c9e..22517772d 100644
--- a/packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts
+++ b/packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts
@@ -62,10 +62,6 @@ const versionDescription: INodeTypeDescription = {
name: 'authentication',
type: 'options',
options: [
- {
- name: 'API Key',
- value: 'airtableApi',
- },
{
name: 'Access Token',
value: 'airtableTokenApi',
@@ -74,10 +70,26 @@ const versionDescription: INodeTypeDescription = {
name: 'OAuth2',
value: 'airtableOAuth2Api',
},
+ {
+ name: 'API Key (Deprecated)',
+ value: 'airtableApi',
+ },
],
default: 'airtableApi',
},
oldVersionNotice,
+ {
+ displayName:
+ "This type of connection (API Key) was deprecated and can't be used anymore. Please create a new credential of type 'Access Token' instead.",
+ name: 'deprecated',
+ type: 'notice',
+ default: '',
+ displayOptions: {
+ show: {
+ authentication: ['airtableApi'],
+ },
+ },
+ },
{
displayName: 'Operation',
name: 'operation',
@@ -552,6 +564,13 @@ export class AirtableV1 implements INodeType {
}
async execute(this: IExecuteFunctions): Promise {
+ const authentication = this.getNodeParameter('authentication', 0);
+ if (authentication === 'airtableApi') {
+ throw new NodeOperationError(
+ this.getNode(),
+ 'The API Key connection was deprecated by Airtable, please use Access Token or OAuth2 instead.',
+ );
+ }
const items = this.getInputData();
const returnData: INodeExecutionData[] = [];
let responseData;
diff --git a/packages/nodes-base/test/nodes/Airtable/Airtable.node.test.ts b/packages/nodes-base/test/nodes/Airtable/Airtable.node.test.ts
index c93598fa0..82b20eaf8 100644
--- a/packages/nodes-base/test/nodes/Airtable/Airtable.node.test.ts
+++ b/packages/nodes-base/test/nodes/Airtable/Airtable.node.test.ts
@@ -44,16 +44,15 @@ describe('Execute Airtable Node', () => {
for (const testData of tests) {
test(testData.description, async () => {
- // execute workflow
- const { result } = await executeWorkflow(testData, nodeTypes);
-
- // check if result node data matches expected test data
- const resultNodeData = Helpers.getResultNodeData(result, testData);
- resultNodeData.forEach(({ nodeName, resultData }) =>
- expect(resultData).toEqual(testData.output.nodeData[nodeName]),
- );
-
- expect(result.finished).toEqual(true);
+ try {
+ // execute workflow
+ await executeWorkflow(testData, nodeTypes);
+ } catch (error) {
+ expect(error).toBeUndefined();
+ expect(error.message).toEqual(
+ 'The API Key connection was deprecated by Airtable, please use Access Token or OAuth2 instead.',
+ );
+ }
});
}
});
diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts
index 84ccddbd1..60f9a3d2c 100644
--- a/packages/workflow/src/Interfaces.ts
+++ b/packages/workflow/src/Interfaces.ts
@@ -2127,7 +2127,7 @@ export interface WorkflowTestData {
[key: string]: any[][];
};
};
- nock: {
+ nock?: {
baseUrl: string;
mocks: Array<{
method: string;