Amplify-cli: UnhandledPromiseRejectionWarning: NoSuchKey: The specified key does not exist.

Created on 1 May 2020  ยท  10Comments  ยท  Source: aws-amplify/amplify-cli

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
Amplify Console GitHub Issue Tracker

Describe the bug

Running amplify init fails with:

โฏ amplify init
Note: It is recommended to run this command from the root of your app directory
? Do you want to use an existing environment? Yes
? Choose the environment you would like to use: dev
Using default provider  awscloudformation
โ ธ Initializing your environment: dev(node:98491) UnhandledPromiseRejectionWarning: NoSuchKey: The specified key does not exist.
    at Request.extractError (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/services/s3.js:835:35)
    at Request.callListeners (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/Users/jason/.nvm/versions/node/v14.1.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:98491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:98491) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
โ ด Initializing your environment: dev

Amplify CLI Version

4.18.1

To Reproduce

  1. Run amplify init in a way in which the cloudformation stack deploys successfully but then fails for some reason (perhaps a lack of S3 permissions, e.g. CreateBucket only).
  2. Fix the cause of the problem above.
  3. Run amplify init again.

Expected behavior

amplify init should complete successfully (or fail with a meaningful error message).

Screenshots

Desktop (please complete the following information):

  • OS: macOS
  • Node Version: 14.1.0

Additional context

This appears to be the same as https://github.com/aws-amplify/amplify-cli/issues/3595

I never had a backup.zip object, amplify init has never completed successfully.

enhancement platform

Most helpful comment

Fixed it by downgrading amplify cli to @aws-amplify/[email protected]

All 10 comments

There seem to be two issues here:

  1. It doesn't handle the fact that the backend zip may not exist (this is also true for amplify delete).
  2. zip-utils doesn't seem to handle the inner promise correctly.

I am a complete noob when it comes to JavaScript but I don't think the outer promise is necessary. Removing it seems to give more sane behaviour.

@steinybot From the transcript above it looks like you're checking out an existing environment. Amplify CLI requires the #current-cloud-backend.zip file to exists when checking out an existing environment, This file contains the state of the environment. Could you check to see if that file exists in the deployment bucket.

@yuth Yes it is an existing environment, one which failed to be created properly and is now stuck. I can't run init nor delete. As I mentioned, the backend.zip does not exist, it never did. There is an invalid assumption that an environment will always contain this backend.zip file.

FWIW, I'm having this same issue, and in my case I actually manually deleted the bucket. I realize I should not have, but the fact remains that my goal is to now start a "fresh" deployment with an amplify project out of source control and I feel like running amplify delete should provide SOME path of using my environment / setting it up new? perhaps something like a --force flag might be useful?

+1

+1000, this is blocking us from onboarding new developers .. no clue what the issue is

FWIW, I'm having this same issue, and in my case I actually manually deleted the bucket. I realize I should not have, but the fact remains that my goal is to now start a "fresh" deployment with an amplify project out of source control and I feel like running amplify delete should provide SOME path of using my environment / setting it up new? perhaps something like a --force flag might be useful?

We may not have all the information needed to tear down the env and I have added this in our backlog to investigate and and fix this.

In the mean time a workaround to fix this might be to update <project-root>/amplify/team-provider-info.json and remove the key with the env name. You will also have to go and delete the stack created for this env and delete the bucket itself using the console.

Fixed it by downgrading amplify cli to @aws-amplify/[email protected]

@pbirsinger could you share the stack trace/error that you get with latest version of the CLI, so I can narrow down the issue

i have the same issue anyone have the solution knowing that the dev and the zip exsist but faild to complet ??

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeanpaulcozzatti picture jeanpaulcozzatti  ยท  3Comments

ReidWeb picture ReidWeb  ยท  3Comments

MageMasher picture MageMasher  ยท  3Comments

jexh picture jexh  ยท  3Comments

onlybakam picture onlybakam  ยท  3Comments