Jeka95 / node-red-contrib-google-cloud

Apache License 2.0
0 stars 1 forks source link

GCP: CE node not working as expected #2

Open Lite5h4dow opened 1 year ago

Lite5h4dow commented 1 year ago

i get the following errors when trying to use the list command without a keyfile name (keyfile is already defined in the credentials. shouldnt require a keyfile)

26 Aug 11:48:13 - [error] TypeError: Cannot read properties of undefined (reading 'keyFilename')
    at /usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:210:26
    at Object.trigger (/usr/src/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at GCEInstanceNode.Node._emitInput (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:202:11)
    at processImmediate (node:internal/timers:466:21)
    at Immediate.<anonymous> (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:831:52)
    at GCEInstanceNode.Node.receive (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:485:10)

and the following without an instance name (shouldnt need to supply an instance name, im trying to list the instances.)

26 Aug 11:52:25 - [error] TypeError: Cannot read properties of undefined (reading 'instance')
    at GCEInstanceNode.Input [as _inputCallback] (/data/node_modules/node-red-contrib-google-cloud-ubos/gce-instance.js:36:81)
    at /usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:210:26
    at Object.trigger (/usr/src/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at GCEInstanceNode.Node._emitInput (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:202:11)
    at GCEInstanceNode.Node.emit (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:186:25)
    at GCEInstanceNode.Node.receive (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:485:10)
    at Immediate.<anonymous> (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:831:52)
    at processImmediate (node:internal/timers:466:21)

however if im using this wrong, then that just stands to reason why there should be documentataion

Lite5h4dow commented 1 year ago

https://github.com/Jeka95/node-red-contrib-google-cloud/pull/3 ive created a PR that should fix the undefined error. @Jeka95 i also took the opportunity to refactor your cluster of if statements. considier using dictionary resolution or switch case statements in future.