Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Image.create options are not passed correctly to Compute.createImage #540

Closed
cschuff opened this issue Jan 20, 2021 · 4 comments · Fixed by #541
Closed

Image.create options are not passed correctly to Compute.createImage #540

cschuff opened this issue Jan 20, 2021 · 4 comments · Fixed by #541
Assignees
Labels
api: compute Issues related to the googleapis/nodejs-compute API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@cschuff
Copy link

cschuff commented Jan 20, 2021

When calling Image.create with parameters disk and options as described the call ends up in the following error:

TypeError: callback is not a function
      at onCreate (.../node_modules/@google-cloud/common/build/src/service-object.js:110:13)

This happens due to the wrong translation of parameters happening in @google-cloud/common/build/src/service-object.js between

The proxy method is not capable of handling any additional parameters...

Parameters end up like follows:
Compute.createImage(
✅ name = imageName,
✅ disk = imageCreate.disk,
⚠️ options = imageCreate.options wrapped as a callback ⚠️,
callback = undefined
)

  1. Is this a client library issue or a product issue?
    This is the client library for nodejs.

  2. Did someone already solve this?
    No

  3. Do you have a support contract?
    Yes, ticket created referencing this github issue

If the support paths suggested above still do not result in a resolution, please provide the following details.

Environment details

  • OS: OS X 11.1
  • Node.js version: 12.19.0
  • npm version: 6.14.8
  • @google-cloud/compute version: 2.4.2

Steps to reproduce

  1. create a VM
  2. create an image using Image.create like follows:
const compute = new Compute({ projectId, keyFilename: this.secretKeyFile });
const disk = compute.zone('europe-west5-a').disk('diskName');
// this line fails with `TypeError: callback is not a function`
const [, operation] = await compute.image('imageName').create(disk, { labels: { foo: 'bar' } });
await new Promise((resolve, reject) => {
    operation.on('complete', (data: any) => resolve(data));
    operation.on('error', (err) => reject(err));
  });
console.log('image successfully captured');

Thanks!

@product-auto-label product-auto-label bot added the api: compute Issues related to the googleapis/nodejs-compute API. label Jan 20, 2021
@cschuff
Copy link
Author

cschuff commented Jan 20, 2021

Furthermore the docs Compute.createImage falsely claims that the returned Promise resolves to

compute.createImage('new-image', disk).then(function(data) {
  var operation = data[0];
  var apiResponse = data[1];
});

while it actually resolves to

compute.createImage('new-image', disk).then(function(data) {
  var image = data[0];
  var operation = data[1];
  var apiResponse = data[2];
});

@stephenplusplus stephenplusplus self-assigned this Jan 20, 2021
@stephenplusplus stephenplusplus added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Jan 20, 2021
@stephenplusplus
Copy link
Contributor

Thanks for reporting! I'll look into this and let you know when I have a PR.

@stephenplusplus
Copy link
Contributor

PR sent! #541. Please take a look!

@sofisl sofisl added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Jan 20, 2021
@cschuff
Copy link
Author

cschuff commented Jan 20, 2021

LGTM

thx!

@bcoe bcoe closed this as completed in #541 Jan 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: compute Issues related to the googleapis/nodejs-compute API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants