Skip to content

Uncaught exception when we have missing request params when calling instancesGroupsClient.list #339

@benbaler

Description

@benbaler

we got this error when using @google-cloud/compute and we unable to catch this error with try/catch (we only able to catch it using process.on('uncaughtException', ...) but its not what we looking for:

/backend/node_modules/google-gax/build/src/transcoding.js:225
            throw new Error(`Required field ${requiredField} is not present in the request.`);
            ^

Error: Required field zone is not present in the request.
    at Object.transcode (/backend/node_modules/google-gax/build/src/transcoding.js:225:19)
    at encodeRequest (/backend/node_modules/google-gax/build/src/fallbackRest.js:52:38)
    at Object.serviceStub.<computed> [as list] (/backend/node_modules/google-gax/build/src/fallbackServiceStub.js:40:37)
    at /backend/node_modules/@google-cloud/compute/build/src/v1/instance_groups_client.js:190:29
    at wrappedCall (/backend/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js:86:20)
    at Immediate.<anonymous> (/backend/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16)
    at processImmediate (node:internal/timers:468:21)
[nodemon] app crashed - waiting for file changes before starting...
  • OS:
  • Node.js version: 16.14.0
  • npm version: 8.31
  • google-gax version: 2.29.5

Steps to reproduce

try {
   const credentials = {email: 'blah', key: 'blah'}
   const instancesGroupsClient = new Compute.InstanceGroupsClient(credentials)

   const [instanceGroupList] = await instancesGroupsClient.list(
      {
       project: projectId,
       zone: null // Intentionally triggers an error!
       }
   )
    
   return instanceGroupList
} catch(e) => {
   console.error("Error - ", e) // will never get here on exception from instancesGroupsClient.list!
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: 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