aws-amplify / aws-amplify/amplify-cli

Amplify migrate api works on sandbox deployment, breaks CI

Open
#9,245 8 comments 1 reaction 0 assignees View on GitHub
bug p2 platform strategic
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### How did you install the Amplify CLI?

yarn

### If applicable, what version of Node.js are you using?

v16.13.0

### Amplify CLI Version

7.6.2

### What operating system are you using?

mac

### Amplify Categories

auth, storage, api

### Amplify Commands

Not applicable

### Describe the bug

We have multiple developers, each working in their own sandbox deployment, under their own App ID, using their own IAM credentials.

We also have a shared App ID, connected to git, with two statically-configured deployments for `master` and `develop` branches, and the Branch Autodetect feature enabled for feature branches.

Using `amplify api migrate` to migrate to GraphQL Transformer v2 works in sandbox deployments and on a newly-created autodetected branch, but fails CI on existing branches once the changes are merged with the following error:

```
2021-12-07T15:08:29.908Z [INFO]: SchemaValidationError: Your GraphQL Schema is using "@hasOne" directive from the newer version of the GraphQL Transformer. Visit https://docs.amplify.aws/cli/migration/transformer-migration/ to learn how to migrate your GraphQL schema.
 at GraphQLTransform.transform (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/GraphQLTransform.ts:247:13)
 at _buildProject (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/amplifyUtils.ts:92:35)
 at processTicksAndRejections (internal/process/task_queues.js:97:5)
 at ensureMissingStackMappings (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/amplifyUtils.ts:166:23)
 at buildProject (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/amplifyUtils.ts:51:3)
 at transformGraphQLSchema (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/transform-graphql-schema.ts:534:29)
 at Object.run (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:166:5)
```

After the merge, our `amplify/cli.json` file looks like this:

```
{
"features": {
"graphqltransformer": {
"addmissingownerfields": true,
"improvepluralization": true,
"validatetypenamereservedwords": true,
"useexperimentalpipelinedtransformer": true,
"enableiterativegsiupdates": true,
"secondarykeyasgsi": true,
"skipoverridemutationinputtypes": true,
"transformerversion": 2,
"suppressschemamigrationprompt": true
},
"frontend-ios": {
"enablexcodeintegration": true
},
"auth": {
"enablecaseinsensitivity": true,
"useinclusiveterminology": true,
"breakcirculardependency": true,
"forcealiasattributes": false
},
"codegen": {
"useappsyncmodelgenplugin": true,
"usedocsgeneratorplugin": true,
"usetypesgeneratorplugin": true,
"cleangeneratedmodelsdirectory": true,
"retaincasestyle": true,
"addtimestampfields": true,
"handlelistnullabilitytransparently": true,
"emitauthprovider": true,
"generateindexrules": true,
"enabledartnullsafety": true
},
"appsync": {
"generategraphqlpermissions": true
},
"latestregionsupport": {
"pinpoint": 1,
"translate": 1,
"transcribe": 1,
"rekognition": 1,
"textract": 1,
"comprehend": 1
},
"project": {
"overrides": true
}
}
}
```

### Expected behavior

The app should deploy successfully using the migrated GraphQL schema.

### Reproduction steps

git co -b migration
amplify api migrate
amplify push
// this results in a SUCCESSFUL deployment in my sandbox environment, using its own App ID

git commit
git push
// this results in a SUCCESSFUL branch deployment using our shared App ID & autodetect branches feature

git co develop
git merge migration
git commit
// this results in a FAILED deploy to our existing `develop` branch deployment

### GraphQL schema(s)

```graphql
# Put schemas below this line
enum Role {
ADMINISTRATOR
CONTRIBUTOR
MEMBER
}

type CompanyUser @model @auth(rules: [{allow: private}]) {
id: ID!
company_id: ID
company: Company @hasOne(fields: ["company_id"])
user_id: ID
position: String
phone: String
email: String
address: Address
roles: Role
}

type User @model @auth(rules: [{allow: private}]) {
id: ID!
companys: [ID]
}

enum AccountType {
CHECKING
SAVING
}

type ACHPaymentMethodInformation {
routing: Int
account_number: Int
account_type: AccountType
}

enum ACHMethodEnum {
ONLY
PREFERRED
ACCEPTED
}

type ACHPaymentMethod {
preference: ACHMethodEnum
information: ACHPaymentMethodInformation
}

type PaymentMethods {
ach: ACHMethodEnum
vcard: String
check: String
}

type Address {
address1: String
address2: String
city: String
state: String
country: String
postal_code: String
}

enum PriorityStatus {
APPROVED
CANCELED
CLOSED
DECLINED
RECEIVED
SUSPENDED
UNDERREVIEW
}

enum CompanyStatus {
VALUE
}

type Company @model @searchable @auth(rules: [{allow: private}]) {
id: ID!
slug: String!
legal_name: String
status: CompanyStatus
account_balance: String
name: String!
dba: String
ein: String
mcc: String
corp_type: String
industry: String
company_email: String
customer_facing_email: String
company_phone: String
website: String
company_address: Address
customer_facing_address: Address
legal_address: Address
admin_user_id: String
accounts_payable_user_id: String
accounts_receivable_user_id: String
payment_methods: PaymentMethods
payment_thresholds: String
speedscore: Int
priority_status: PriorityStatus
priority_buyer_id: String
deleted_at: AWSDateTime
company_id: String!
logo: String
}

type ModelCompanyConnection {
items: [Company]
nextToken: String
total: Int
}

enum PaymentFileQueueStatusEnum {
PROCESSED
QUEUED
}

type PaymentFileQueue @model @auth(rules: [{allow: private}]) {
id: ID!
key: String!
status: PaymentFileQueueStatusEnum!
queued_at: AWSDateTime
processed_at: AWSDateTime
company_id: ID
company: Company @hasOne(fields: ["company_id"])
}

```

### Log output

```
# Put your logs below this line
# Starting phase: build
# Executing command: node -v
2021-12-07T15:08:02.729Z [INFO]: v12.21.0
2021-12-07T15:08:14.077Z [INFO]: Amplify AppID found: ddzxwz9kd3xor. Amplify App name is: speedchainr2
2021-12-07T15:08:14.149Z [INFO]: Backend environment develop found in Amplify Console app: speedchainr2
2021-12-07T15:08:15.418Z [WARNING]: - Fetching updates to backend environment: develop from the cloud.
2021-12-07T15:08:16.284Z [WARNING]: - Building resource auth/speedchainr2726bb6be726bb6be
2021-12-07T15:08:16.343Z [WARNING]: - Building resource api/speedchainr2
2021-12-07T15:08:16.459Z [INFO]: ⚠️ Your instance type for OpenSearch is t2.small.elasticsearch, you may experience performance issues or data loss. Consider reconfiguring with the instructions here https://docs.amplify.aws/cli-legacy/graphql-transformer/searchable/
2021-12-07T15:08:16.758Z [WARNING]: - Building resource storage/speedchainstorage
2021-12-07T15:08:16.853Z [WARNING]: ✔ Successfully pulled backend environment develop from the cloud.
2021-12-07T15:08:16.881Z [INFO]:
2021-12-07T15:08:21.919Z [INFO]: Note: It is recommended to run this command from the root of your app directory
2021-12-07T15:08:27.859Z [WARNING]: - Initializing your environment: develop
2021-12-07T15:08:29.076Z [WARNING]: - Building resource auth/speedchainr2726bb6be726bb6be
2021-12-07T15:08:29.133Z [WARNING]: - Building resource api/speedchainr2
2021-12-07T15:08:29.245Z [INFO]: ⚠️ Your instance type for OpenSearch is t2.small.elasticsearch, you may experience performance issues or data loss. Consider reconfiguring with the instructions here https://docs.amplify.aws/cli-legacy/graphql-transformer/searchable/
2021-12-07T15:08:29.496Z [WARNING]: - Building resource storage/speedchainstorage
2021-12-07T15:08:29.556Z [WARNING]: ✔ Initialized provider successfully.
2021-12-07T15:08:29.639Z [INFO]: ⚠️ Your instance type for OpenSearch is t2.small.elasticsearch, you may experience performance issues or data loss. Consider reconfiguring with the instructions here https://docs.amplify.aws/cli-legacy/graphql-transformer/searchable/
2021-12-07T15:08:29.891Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud
2021-12-07T15:08:29.892Z [WARNING]: ✖ There was an error initializing your environment.
2021-12-07T15:08:29.908Z [INFO]: SchemaValidationError: Your GraphQL Schema is using "@hasOne" directive from the newer version of the GraphQL Transformer. Visit https://docs.amplify.aws/cli/migration/transformer-migration/ to learn how to migrate your GraphQL schema.
 at GraphQLTransform.transform (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/GraphQLTransform.ts:247:13)
 at _buildProject (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/amplifyUtils.ts:92:35)
 at processTicksAndRejections (internal/process/task_queues.js:97:5)
 at ensureMissingStackMappings (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/amplifyUtils.ts:166:23)
 at buildProject (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/amplifyUtils.ts:51:3)
 at transformGraphQLSchema (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/transform-graphql-schema.ts:534:29)
 at Object.run (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:166:5)
2021-12-07T15:08:29.932Z [ERROR]: !!! Build failed
2021-12-07T15:08:29.933Z [ERROR]: !!! Non-Zero Exit Code detected
2021-12-07T15:08:29.933Z [INFO]: # Starting environment caching...
2021-12-07T15:08:29.933Z [INFO]: # Uploading environment cache artifact...
2021-12-07T15:08:30.000Z [INFO]: # Environment caching completed
Terminating logging...

```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.