Skip to content

Spanner requests failing as invalid if the project ID isn't set explicitly #2086

@jgeewax

Description

@jgeewax

It seems like we're not properly constructing the request?

I first noticed this when trying to get the schema of a table (I'd already run gcloud config set project <myproject>)

> var gcloud = require('google-cloud');
undefined
> var spanner = gcloud.spanner();
undefined
> var instance = spanner.instance('my-instance');
undefined
> var db = instance.database('my-db');
undefined
> db.getSchema(console.log);
undefined
> { Error: Invalid GetDatabaseDdl request.
    at /usr/local/google/home/jjg/node_modules/google-cloud/node_modules/grpc/src/node/src/client.js:434:17
  code: 3,
  metadata: 
   Metadata {
     _internal_repr: 
      { 'google.rpc.badrequest-bin': [Object],
        'google.rpc.debuginfo-bin': [Object] } },
  note: 'Exception occurred in retry method that was not classified as transient' }

Then thought that I should try it higher up the chain...

> instance.exists(console.log);
undefined
> { Error: Invalid GetInstance request.
    at /usr/local/google/home/jjg/node_modules/google-cloud/node_modules/grpc/src/node/src/client.js:434:17
  code: 3,
  metadata: 
   Metadata {
     _internal_repr: 
      { 'google.rpc.badrequest-bin': [Object],
        'google.rpc.debuginfo-bin': [Object] } },
  note: 'Exception occurred in retry method that was not classified as transient' }

I tried re-creating the spanner object with an explicit project ID, and that fixed the problem.

Can we throw a better error if the project ID wasn't detected? Saying "the request was invalid" is super not helpful.

Metadata

Metadata

Labels

api: spannerIssues related to the Spanner API.coretype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions