Skip to content

Commit a6fa42e

Browse files
authored
fix: specifically catch AppSync 'Code contains one or more errors' (#2264)
* fix: specifically catch AppSync 'Code contains one or more errors' * PR Updates
1 parent 716f844 commit a6fa42e

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

.changeset/early-suits-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-deployer': patch
3+
---
4+
5+
specifically catch AppSync "Code contains one or more errors"

packages/backend-deployer/src/cdk_error_mapper.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ const testErrorMappings = [
163163
expectedDownstreamErrorMessage: undefined,
164164
},
165165
{
166-
errorMessage: `[31m some-stack failed: The stack named some-stack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: The code contains one or more errors. (Service: AppSync, Status Code: 400, Request ID: 12345) (RequestToken: 123, HandlerErrorCode: GeneralServiceException), Embedded stack <escaped ARN> was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to create: [resource1, resource2]. [39m`,
166+
errorMessage: `[31m some-stack failed: The stack named some-stack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: Some amazing error message (Service: AppSync, Status Code: 400, Request ID: 12345) (RequestToken: 123, HandlerErrorCode: GeneralServiceException), Embedded stack <escaped ARN> was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to create: [resource1, resource2]. [39m`,
167167
expectedTopLevelErrorMessage: 'The CloudFormation deployment has failed.',
168168
errorName: 'CloudFormationDeploymentError',
169-
expectedDownstreamErrorMessage: `The stack named some-stack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: The code contains one or more errors. (Service: AppSync, Status Code: 400, Request ID: 12345) (RequestToken: 123, HandlerErrorCode: GeneralServiceException), Embedded stack <escaped ARN> was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to create: [resource1, resource2]. [39m`,
169+
expectedDownstreamErrorMessage: `The stack named some-stack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: Some amazing error message (Service: AppSync, Status Code: 400, Request ID: 12345) (RequestToken: 123, HandlerErrorCode: GeneralServiceException), Embedded stack <escaped ARN> was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to create: [resource1, resource2]. [39m`,
170170
},
171171
{
172172
errorMessage: `[31m some-stack failed: The stack named some-stack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE`,
@@ -406,6 +406,22 @@ npm error A complete log of this run can be found in: /home/some-path/.npm/_logs
406406
errorName: 'AccessDeniedError',
407407
expectedDownstreamErrorMessage: undefined,
408408
},
409+
{
410+
errorMessage: `amplify-stack-user-sandbox failed: BadRequestException: The code contains one or more errors.`,
411+
expectedTopLevelErrorMessage:
412+
'A custom resolver used in your defineData contains one or more errors',
413+
errorName: 'AppSyncResolverSyntaxError',
414+
expectedDownstreamErrorMessage:
415+
'amplify-stack-user-sandbox failed: BadRequestException: The code contains one or more errors.',
416+
},
417+
{
418+
errorMessage: `Deployment failed: Error: The stack named amplify-stack-user-sandbox failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: The code contains one or more errors. (Service: AppSync, Status Code: 400,...`,
419+
expectedTopLevelErrorMessage:
420+
'A custom resolver used in your defineData contains one or more errors',
421+
errorName: 'AppSyncResolverSyntaxError',
422+
expectedDownstreamErrorMessage:
423+
'Deployment failed: Error: The stack named amplify-stack-user-sandbox failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: The code contains one or more errors. (Service: AppSync, Status Code: 400,...',
424+
},
409425
{
410426
errorMessage: `User: some:great:user is not authorized to perform: appsync:StartSchemaCreation on resource: arn:aws:appsync:us-east-1:235494812930:/v1/api/myApi`,
411427
expectedTopLevelErrorMessage:

packages/backend-deployer/src/cdk_error_mapper.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,29 @@ export class CdkErrorMapper {
381381
errorName: 'SecretNotSetError',
382382
classification: 'ERROR',
383383
},
384+
{
385+
errorRegex:
386+
/BadRequestException: The code contains one or more errors|The code contains one or more errors.*AppSync/,
387+
humanReadableErrorMessage: `A custom resolver used in your defineData contains one or more errors`,
388+
resolutionMessage: `Check for any syntax errors in your custom resolvers code.`,
389+
errorName: 'AppSyncResolverSyntaxError',
390+
classification: 'ERROR',
391+
},
392+
// Generic error printed by CDK. Order matters so keep this towards the bottom of this list
393+
{
394+
// Error: .* is printed to stderr during cdk synth
395+
// Also extracts the first line in the stack where the error happened
396+
errorRegex: new RegExp(
397+
`^Error: (.*${this.multiLineEolRegex}.*at.*)`,
398+
'm'
399+
),
400+
humanReadableErrorMessage:
401+
'Unable to build the Amplify backend definition.',
402+
resolutionMessage:
403+
'Check your backend definition in the `amplify` folder for syntax and type errors.',
404+
errorName: 'BackendSynthError',
405+
classification: 'ERROR',
406+
},
384407
{
385408
errorRegex:
386409
/(?<stackName>amplify-[a-z0-9-]+)(.*) failed: ValidationError: Stack:(.*) is in (?<state>.*) state and can not be updated/,
@@ -407,6 +430,7 @@ export class CdkErrorMapper {
407430

408431
export type CDKDeploymentError =
409432
| 'AccessDeniedError'
433+
| 'AppSyncResolverSyntaxError'
410434
| 'BackendBuildError'
411435
| 'BackendSynthError'
412436
| 'BootstrapNotDetectedError'

0 commit comments

Comments
 (0)