From dcd5432f1451c8be576a7ac1ed1a414e7ccd00d8 Mon Sep 17 00:00:00 2001 From: Armando Luja Date: Wed, 11 Dec 2024 13:31:54 -0800 Subject: [PATCH 1/2] chore: reclassify generate schema-from-database error --- .../backend-deployer/src/cdk_error_mapper.test.ts | 7 +++++++ packages/backend-deployer/src/cdk_error_mapper.ts | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/backend-deployer/src/cdk_error_mapper.test.ts b/packages/backend-deployer/src/cdk_error_mapper.test.ts index f20049121e..7fc68eeb4e 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.test.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.test.ts @@ -621,6 +621,13 @@ npm error enoent`, errorName: 'CloudFormationDeletionError', expectedDownstreamErrorMessage: undefined, }, + { + errorMessage: `No valid tables found. Make sure at least one table has a primary key.`, + expectedTopLevelErrorMessage: + 'No valid tables found. Make sure at least one table has a primary key.', + errorName: 'GenerateSchemaFromDatabaseError', + expectedDownstreamErrorMessage: undefined, + }, ]; void describe('invokeCDKCommand', { concurrency: 1 }, () => { diff --git a/packages/backend-deployer/src/cdk_error_mapper.ts b/packages/backend-deployer/src/cdk_error_mapper.ts index 5044b430ab..80bf58f115 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.ts @@ -453,6 +453,16 @@ export class CdkErrorMapper { errorName: 'CloudFormationDeploymentError', classification: 'ERROR', }, + { + errorRegex: + /No valid tables found\. Make sure at least one table has a primary key\./, + humanReadableErrorMessage: + 'No valid tables found. Make sure at least one table has a primary key.', + resolutionMessage: + "If you are using the 'generate schema-from-database' command, make sure the database has at least one table with a primary key.", + errorName: 'GenerateSchemaFromDatabaseError', + classification: 'ERROR', + }, { // Note that the order matters, this should be the last as it captures generic CFN error errorRegex: new RegExp( @@ -493,4 +503,5 @@ export type CDKDeploymentError = | 'InvalidPackageJsonError' | 'SecretNotSetError' | 'SyntaxError' - | 'GetLambdaLayerVersionError'; + | 'GetLambdaLayerVersionError' + | 'GenerateSchemaFromDatabaseError'; From 88fc41de23699776f5041fd58f9ba62f4338aea8 Mon Sep 17 00:00:00 2001 From: Armando Luja Date: Wed, 11 Dec 2024 13:43:09 -0800 Subject: [PATCH 2/2] chore: add changeset --- .changeset/clean-panthers-draw.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/clean-panthers-draw.md diff --git a/.changeset/clean-panthers-draw.md b/.changeset/clean-panthers-draw.md new file mode 100644 index 0000000000..35a42e0fd4 --- /dev/null +++ b/.changeset/clean-panthers-draw.md @@ -0,0 +1,5 @@ +--- +'@aws-amplify/backend-deployer': patch +--- + +Added cdk error mapping for 'No valid tables found.'