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

fix(AWS DynamoDB Node): Improve error message parsing #7793

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ export async function awsApiRequest(
(await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions)) as string,
);
} catch (error) {
const errorMessage =
const statusCode = (error.statusCode || error.cause?.statusCode) as number;
let errorMessage =
error.response?.body?.message || error.response?.body?.Message || error.message;
if (error.statusCode === 403) {

if (statusCode === 403) {
if (errorMessage === 'The security token included in the request is invalid.') {
throw new Error('The AWS credentials are not valid!');
} else if (
Expand All @@ -51,7 +53,13 @@ export async function awsApiRequest(
}
}

throw new Error(`AWS error response [${error.statusCode}]: ${errorMessage}`);
if (error.cause?.error) {
try {
errorMessage = JSON.parse(error.cause?.error).message;
} catch (ex) {}
}

throw new Error(`AWS error response [${statusCode}]: ${errorMessage}`);
}
}

Expand Down
Loading