Skip to content

Commit d345f22

Browse files
laljikanjareeyaGautamSharda
authored andcommitted
fix: cluster id store as undefined in createInstance request (#654)
* fix: cluster id store as undefined
1 parent 0a75aa6 commit d345f22

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

handwritten/bigtable/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,12 @@ export class Bigtable {
641641
}
642642

643643
reqOpts.clusters = arrify(options.clusters!).reduce((clusters, cluster) => {
644+
if (!cluster.id) {
645+
throw new Error(
646+
'A cluster was provided without an `id` property defined.'
647+
);
648+
}
649+
644650
clusters[cluster.id!] = {
645651
location: Cluster.getLocation_(this.projectId, cluster.location!),
646652
serveNodes: cluster.nodes,

handwritten/bigtable/test/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,23 @@ describe('Bigtable', () => {
489489
done();
490490
});
491491
});
492+
493+
it('should throw an error if cluster id not provided.', () => {
494+
const options = {
495+
displayName: 'my-sweet-instance',
496+
labels: {env: 'prod'},
497+
clusters: [
498+
{
499+
nodes: 3,
500+
location: 'us-central1-b',
501+
storage: 'ssd',
502+
},
503+
],
504+
};
505+
assert.throws(() => {
506+
bigtable.createInstance(INSTANCE_ID, options);
507+
}, /A cluster was provided without an `id` property defined\./);
508+
});
492509
});
493510

494511
describe('getInstances', () => {

0 commit comments

Comments
 (0)