Skip to content
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

Constructors require options object #2750

Closed
thefill opened this issue Nov 19, 2017 · 3 comments
Closed

Constructors require options object #2750

thefill opened this issue Nov 19, 2017 · 3 comments
Assignees
Labels

Comments

@thefill
Copy link

thefill commented Nov 19, 2017

Datastore module for nodejs fails to use application-default-credentials or GOOGLE_APPLICATION_CREDENTIALS env variable.

Environment details

  • OS: macOS High Sierra 10.13.1 (17B48)
  • Node.js version: v6.11.5 | v8.1.2
  • npm version: 3.10.10
  • yarn version: 0.21.3
  • google-cloud-node version:
    • google-cloud/datastore: "^1.1.0"
  • gcloud version
    • Google Cloud SDK 178.0.0
    • beta 2017.09.15
    • bq 2.0.27
    • core 2017.10.30
    • gsutil 4.28

Steps to reproduce

  1. setup gcloud via "gcloud init"
  2. For failure with application-default-credentials
    a. gcloud beta auth application-default login
    b. command informs that ~/.config/gcloud/application_default_credentials.json has been created
    c. all documentations suggests that datastore should work when user authenticate via gcloud
    d. in node app:
    import * as Datastore from "@google-cloud/datastore";
    const datastore = new Datastore();
    
    c. error returned in console
    Cannot read property 'apiEndpoint' of undefined
    
  3. For failure with GOOGLE_APPLICATION_CREDENTIALS env variable
    a. create & download json service account key via google console
    b. Set env variable
    export GOOGLE_APPLICATION_CREDENTIALS=/some/path/to/key.json
    
    c. all documentations suggests that datastore should check env variable GOOGLE_APPLICATION_CREDENTIALS for path to the key file
    d. in node app:
    import * as Datastore from "@google-cloud/datastore";
    const datastore = new Datastore();
    
    c. error returned in console
    Cannot read property 'apiEndpoint' of undefined
    
  4. What works:
    a. create & download json service account key via google console
    d. in node app:
    import * as Datastore from "@google-cloud/datastore";
    const datastore = new Datastore({
         keyFilename: '/some/path/to/key.json'
    });
    
    c. no error returned, datastore client works

Am I doing something wrong? Is that a correct behaviour?

This forces a developer to hardcode the path to credentials while in local dev.

@thefill thefill changed the title Datastore client fails to instantiate in local functions-emulator Datastore client fails to instantiate in local environment Nov 19, 2017
@stephenplusplus stephenplusplus changed the title Datastore client fails to instantiate in local environment Constructors require options object Nov 19, 2017
@stephenplusplus
Copy link
Contributor

This is actually an issue with our constructors requiring an options object. In those scenarios, this will work:

import * as Datastore from "@google-cloud/datastore";
const datastore = new Datastore({}); // annoying empty object

Sorry for the inconvenience. We will fix it.

@stephenplusplus stephenplusplus added core priority: p2 Moderately-important priority. Fix may not be included in next release. labels Nov 19, 2017
@thefill
Copy link
Author

thefill commented Nov 20, 2017

@stephenplusplus indeed empty object cleared the issue. Thanks for an ultra-fast response ;-)

@stephenplusplus
Copy link
Contributor

This issue was moved to googleapis/nodejs-common#14.

@stephenplusplus stephenplusplus removed the priority: p2 Moderately-important priority. Fix may not be included in next release. label Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants