Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS DynamoDB Error improvements, Optional GetAll Scan FilterExpression - N8N-3701 #3318

Merged
merged 10 commits into from
Jul 10, 2022
12 changes: 10 additions & 2 deletions packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,13 @@ export class AwsDynamoDB implements INodeType {

const body: IRequestBody = {
TableName: this.getNodeParameter('tableName', i) as string,
ExpressionAttributeValues: adjustExpressionAttributeValues(eavUi),
};

if (scan === true) {
body['FilterExpression'] = this.getNodeParameter('filterExpression', i) as string;
const filterExpression = this.getNodeParameter('filterExpression', i) as string;
if (filterExpression) {
body['FilterExpression'] = filterExpression;
}
} else {
body['KeyConditionExpression'] = this.getNodeParameter('keyConditionExpression', i) as string;
}
Expand All @@ -332,6 +334,12 @@ export class AwsDynamoDB implements INodeType {
body.ExpressionAttributeNames = expressionAttributeName;
}

const expressionAttributeValues = adjustExpressionAttributeValues(eavUi);

if (Object.keys(expressionAttributeValues).length) {
body.ExpressionAttributeValues = expressionAttributeValues;
}

if (indexName) {
body.IndexName = indexName;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
try {
return JSON.parse(await this.helpers.request!(options));
} catch (error) {
const errorMessage = (error.response && error.response.body.message) || (error.response && error.response.body.Message) || error.message;
const errorMessage = (error.response && error.response.body && error.response.body.message) || (error.response && error.response.body && error.response.body.Message) || error.message;
if (error.statusCode === 403) {
if (errorMessage === 'The security token included in the request is invalid.') {
throw new Error('The AWS credentials are not valid!');
Expand Down
9 changes: 4 additions & 5 deletions packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export const itemFields: INodeProperties[] = [
],
},
],
description: 'Item\'s primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key',
description: 'Item\'s primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.',
},
{
displayName: 'Simplify',
Expand Down Expand Up @@ -593,7 +593,7 @@ export const itemFields: INodeProperties[] = [
],
},
],
description: 'Item\'s primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key',
description: 'Item\'s primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.',
},
{
displayName: 'Additional Fields',
Expand Down Expand Up @@ -695,7 +695,6 @@ export const itemFields: INodeProperties[] = [
displayName: 'Filter Expression',
name: 'filterExpression',
type: 'string',
required: true,
displayOptions: {
show: {
scan: [
Expand All @@ -704,7 +703,7 @@ export const itemFields: INodeProperties[] = [
},
},
default: '',
description: 'A filter expression determines which items within the Scan results should be returned to you. All of the other results are discarded.',
description: 'A filter expression determines which items within the Scan results should be returned to you. All of the other results are discarded. Empty value will return all Scan results.',
},
{
displayName: 'Key Condition Expression',
Expand Down Expand Up @@ -912,7 +911,7 @@ export const itemFields: INodeProperties[] = [
name: 'projectionExpression',
type: 'string',
default: '',
description: 'Text that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas',
description: 'Text that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas.',
},
{
displayName: 'Filter Expression',
Expand Down