balena-io / balena-cli

The official balena CLI tool.
Apache License 2.0
452 stars 138 forks source link

"Cannot read property 'app_name' of undefined" from "resin ssh" #544

Open pimterry opened 7 years ago

pimterry commented 7 years ago

https://sentry.io/resinio/cli/issues/289095802/

TypeError: Cannot read property 'app_name' of undefined
  File "/usr/lib/node_modules/resin-cli/node_modules/resin-sdk/build/models/device.js", line 140, in addExtraInfo
    device.application_name = device.application[0].app_name;
  File "/usr/lib/node_modules/resin-cli/node_modules/bluebird/js/release/util.js", line 16, in tryCatcher
    return target.apply(this, arguments);
  File "/usr/lib/node_modules/resin-cli/node_modules/bluebird/js/release/map.js", line 61, in MappingPromiseArray._promiseFulfilled
    var ret = tryCatch(callback).call(receiver, value, index, length);
  File "/usr/lib/node_modules/resin-cli/node_modules/bluebird/js/release/promise_array.js", line 114, in MappingPromiseArray.PromiseArray._iterate
    isResolved = this._promiseFulfilled(maybePromise, i);
  File "/usr/lib/node_modules/resin-cli/node_modules/bluebird/js/release/promise_array.js", line 78, in MappingPromiseArray.init
    this._iterate(values);
...
(9 additional frame(s) were not displayed)

TypeError: Cannot read property 'app_name' of undefined
imrehg commented 7 years ago

@pimterry I seem get something like this with resin sync:

$ resin sync -s .   
Cannot read property 'app_name' of undefined

but if I add the device UUID, then it works:

$ resin sync -s . ed01bfe
? Destination directory on device container [/usr/src/app] 
Getting information for device: ed01bfe
Got application container info.
...

Is there anything I can test? (using resin-cli 6.6.5)

imrehg commented 7 years ago

@pimterry also, just issuing resin devices to list all of my devices seems to have the issue too..

$ resin devices
Cannot read property 'app_name' of undefined
lekkas commented 7 years ago

Possibly related to https://github.com/resin-io/resin-cli/issues/654

pimterry commented 6 years ago

@imrehg sorry I missed this while I was away, back now! This is fascinating. That error is because we're successfully loading the device from the API, but not getting the application back with it, almost as if it's a device that exists outside an application.

The main thing I need to debug this further is a reliable way to reproduce this. How did you get into this state? Is there anything unusual about the device or its application? Are you collaborator on somebody else's app here, as Kostas suggests?

imrehg commented 6 years ago

@pimterry this happened during the testing of a resinOS release. The app is just mine, and neither the app, nor the device was shared with another user.

Now retrying it (different app, different device), I have these experience (resin-cli 6.6.5):

Sorry if it's confusing, as I'm confused too now, it might be multiple things going wrong, or misunderstood. :/ Happy to test anything that you might think to be useful.

Edit: the resin devices part is erroring out the same way as before on 6.6.6. I have some applications shared with me, but there's a lot application I have at hand. Happy to give you a token if checking out my fleet would be helpful....

imrehg commented 6 years ago

This issue still bugs me. Can't do resin devices on my setup, as it always just errors. (6.12.5 now)

pimterry commented 6 years ago

@imrehg this is really weird. Can you run JSON.stringify(await sdk.models.device.getAll()) in the browser console on the web dashboard, and send me the JSON you get back? That's more or less the underlying SDK command the CLI is running, and somehow it must be returning some device data in there that's in an odd state we're not expecting.

imrehg commented 6 years ago

@pimterry the result is (a bit big): https://www.flowdock.com/app/rulemotion/resin-frontend/threads/iHwow5Hr37NcDUV3mfFPNswXWou

pimterry commented 6 years ago

Discussion continued in the flowdock thread. Short answer: this happens if you have a device that you own, in an application that you no longer have access to.

pimterry commented 6 years ago

We're going to have a product call and discuss this more widely, since it's part of a larger issue. As a short-term mitigation, if you end up in this situtation, right now I think you need to either move the device into an app you do own, using the API directly, or delete the device entirely.

pdcastro commented 4 years ago

TypeError: Cannot read property 'app_name' of undefined

The error can no longer be found in Sentry.io.

this happens if you have a device that you own, in an application that you no longer have access to

I understand that API changes were made since this issue was created, to prevent this situation from arising.

I am closing this issue for the reasons above. However if you come across this problem again, please add a comment and I will reopen it and investigate it further.

pdcastro commented 4 years ago

I understand that API changes were made since this issue was created, to prevent this situation from arising.

Or maybe not. Re-opening this issue as the error was reported again: