Skip to content

Add more helpful error message for improper config #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2017

Conversation

alexdebrie
Copy link
Contributor

This adds a more helpful error message for those that don't change the project value from the template in serverless.yml. It now says:

  Error --------------------------------------------------

  Error: Incorrect configuration. Please change the 'project' key in the 'provider' block in your Serverless config file.

Why is this helpful?

The serverless.yml template looks like this:

provider:
  name: google
  runtime: nodejs
  project: my-project
  # the path to the credentials file needs to be absolute
  credentials: ~/.gcloud/keyfile.json

If you don't change the project value to the ID for your project, you'll get this error:

  Error --------------------------------------------------

  Error: Access Not Configured. Google Cloud Deployment Manager API has not been used in project 1043443670838 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/deploymentmanager.googleapis.com/overview?project=1043443670838 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

This happened to me, and two other users have reported it in the last few days. It's very confusing because I had enabled those APIs, but the real problem was that I was using the wrong project. Clicking the link in that error message wasn't helpful because that project doesn't exist in my GCP account.

Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this PR @alexdebrie 👍

Just looked through the code and added one comment.

AFAIK googleProvider.js is not 100% covered by tests. Can you confirm that you've tested it thoroughly?

Thanks again for working on this fix!

@@ -64,7 +64,11 @@ class GoogleProvider {
} else {
// support for API calls with arbitraty deepness
filArgs.reduce((p, c) => p[c], this.sdk)(requestParams, (error, response) => {
if (error) reject(new Error(error));
if (error && error.errors && error.errors[0].message && error.errors[0].message.includes('project 1043443644444')) {
Copy link
Contributor

@pmuens pmuens Oct 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 1043443644444 a Google Cloud Functions error code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1043443644444 is the Id number of my-project.

From what I understand, a project name is unique across all GCP, and each project had an Id number. We put my-project in the serverless.yml for the GCF template. If you don't change that, it will spit an error about project 1043443644444 not being configured correctly.

@alexdebrie
Copy link
Contributor Author

Thanks, @pmuens.

Yep, I tested thoroughly. Also, it's pretty safe / low impact -- does some very careful checking of the error object and only throws a different error in a pretty specific circumstance.

Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying and fixing that @alexdebrie 👍

Merging... :shipit:

@pmuens pmuens merged commit 043516f into master Oct 26, 2017
@pmuens pmuens deleted the ProjectNameError branch October 26, 2017 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants