user3162553
user3162553

Reputation: 2859

Amplify (Flutter app) push stuck on previous build's schema

I have an Amplify project where I've generated some GraphQL schema models. I previously deployed invalid syntax but the push otherwise completed successfully. However, I've corrected the error and tried to repush but I see the same previous syntax error that now no longer exists in the project.

Basically, if you run into modelgen error on a push, it bricks your application and you must start over because Amplify cannot get out of the failed state.

Things I've tried:

  1. Destructive update flag
amplify push --allow-destructive-graphql-schema-updates 
  1. Push after pull
amplify pull
(fix syntax again)
amplify push
  1. Manually add another change to 'break' cache

  2. Push with force

amplify push --force
  1. Updating api
amplify update api --allow-destructive-graphql-schema-updates
(remove conflict resolution)
(succeeds at update)
amplify push (fails with same error)
  1. Force and allow destructive update
amplify push --force --allow-destructive-graphql-schema-update
  1. Pull to restore
amplify pull --restore

The restore fails with the same bad syntax error

  1. Amplify re-init
amplify init
amplify codegen models
amplify status -v (change is present)
amplify push --force -y

Same error is now observed

  1. Modifying local build cache to manually remove error

/amplify/#current-cloud-backend/api/{api_name}/schema.graphql

  1. Rebuilding The API

amplify rebuild api

  1. Pray to Zeus

Each time I run into the same syntax error as before.

How can I force push my changes locally which do not contain the syntax error? Basically, I'm wondering if there's an equivalent to

git push main --force

I'm guessing that Amplify is storing these hashes somewhere in S3 but I'm just baffled as to how the push doesn't break that cache or why it would be the same syntax error which no longer is in the project at all.

Extra possible context: https://github.com/aws-amplify/amplify-codegen/issues/220

Looks like bad state really requires the app to be deleted.

Amplify version (7.6.22)

Upvotes: 2

Views: 1154

Answers (2)

Ivaan Chin
Ivaan Chin

Reputation: 31

  1. Navigate to the s3 console AWS S3 Console

  2. Identify the deployment bucket of your app Deployment Bucket

  3. Download #current-cloud-backend.zip unzip the contents. Be sure to not accidentally zip as a nested folder: unzip "#current-cloud-backend.zip" -d "#current-cloud-backend" mv "#current-cloud-backend.zip" backup.zip

  4. Correct the GraphQL schema and re-zip the folder. cd "#current-cloud-backend"; zip -r "../#current-cloud-backend.zip" *

  5. Re-upload the newly zipped archive to your s3 deployment bucket.

  6. Push from local machine with amplify push --force.

Referenced from https://github.com/aws-amplify/amplify-cli/issues/10118

Upvotes: 1

Esteban Sosa
Esteban Sosa

Reputation: 1

Got the latest cloud formation that worked with amplify pull, I did amplify function remove in one function I was having a similar problem, did a backup before doing the remove, then amplify push, then added the function again, amplify add function, and added my updated code back, then again amplify status and amplify push., is a bummer I know.

Upvotes: 0

Related Questions