GeezerVison is showing github.com — Datastore client not getting ProjectID from env · Issue #1092 · googleapis/google-cloud-node
Datastore client not getting ProjectID from env #1092Labels api: datastoreIssues related to the Datastore API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DescriptionIt looks like Datastore client is not getting the projectID from the env automatically.
var pubsub = gcloud.pubsub();
This works fine, but:
var dataset = gcloud.datastore.dataset();
returns:
Error: Sorry, we cannot connect to Google Cloud Services without a project ID. You may specify one with an environment variable named "GCLOUD_PROJECT". See https://googlecloudplatform.github.io/gcloud-node/#/authentication for a detailed guide on creating an authenticated connection.
This fixes the problem
var dataset = gcloud.datastore.dataset({projectId: process.env.GCLOUD_PROJECT});Activitystephenplusplus commented on Jan 27, 2016 Good catch, thanks for letting us know. PR incoming! thesandlord commented on Jan 27, 2016 im not sure if other clients also have this problem. I though they all extend the same base class? stephenplusplus commented on Jan 27, 2016 I checked, all of the other APIs do it.
@callmehiphop can you think of a way we can move the normalizing to the Service constructor? callmehiphop commented on Jan 28, 2016 @stephenplusplus we should be able to just normalize them in the Service constructor, no? stephenplusplus commented on Jan 28, 2016 callmehiphop commented on Jan 28, 2016 Service.call(...) only gets called once IIRC - after a service class has been instantiated.. right?
stephenplusplus commented on Jan 29, 2016 stephenplusplus commented on Jan 29, 2016 callmehiphop commented on Jan 29, 2016
Why do we only normalize if it's not an instance of Storage?
If the current context is not an instance of a service (e.g. Storage), that implies that the context is probably gcloud, which is where we store global config. stephenplusplus commented on Jan 29, 2016 So I'm wondering, since we only normalize under that condition, how do we move that logic to the Service constructor? callmehiphop commented on Jan 29, 2016
So I'm wondering, since we only normalize under that condition, how do we move that logic to the Service constructor?
Ahh right, not sure if there's a way around that.. we might have to re-think things a little bit if we want to try and refactor that logic into the Service class.
MetadataMetadataapi: datastoreIssues related to the Datastore API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DevelopmentNo branches or pull requestsIssue actions
|