balena-io-modules / balena-preload

Script for preloading containers onto balena device images
https://www.balena.io/
Apache License 2.0
35 stars 8 forks source link

TypeError: Cannot read property '0' of undefined #221

Closed pdcastro closed 4 years ago

pdcastro commented 4 years ago

I attempted updating the balena CLI to use balena-preload v10.0.0, but I got:

$ DEBUG=1 ./bin/balena preload ~/Downloads/balena.img --app test-nuc --splash-image ~/Downloads/resinio.png
...
? Select a release current
- Cleaning up temporary files
Cannot read property '0' of undefined

TypeError: Cannot read property '0' of undefined
    at Preloader._ensureCanPreload (/home/paulo/balena/balena-io/balena-cli/node_modules/balena-preload/lib/preload.js:673:88)
    at /home/paulo/balena/balena-io/balena-cli/node_modules/balena-preload/lib/preload.js:714:12
From previous event:
    at Preloader.preload (/home/paulo/balena/balena-io/balena-cli/node_modules/balena-preload/lib/preload.js:713:6)
    at /home/paulo/balena/balena-io/balena-cli/build/actions/preload.js:317:43
From previous event:
    at /home/paulo/balena/balena-io/balena-cli/build/actions/preload.js:317:22
    at new Promise (<anonymous>)
    at /home/paulo/balena/balena-io/balena-cli/build/actions/preload.js:286:20
    at processImmediate (internal/timers.js:456:21)
From previous event:
    at Command.action (/home/paulo/balena/balena-io/balena-cli/build/actions/preload.js:268:47)
    at /home/paulo/balena/balena-io/balena-cli/node_modules/capitano/build/command.js:98:37
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at runNextTicks (internal/process/task_queues.js:66:3)
    at processImmediate (internal/timers.js:429:9)
    at process.topLevelDomainCallback (domain.js:137:15)

The error happens on the following line of PR #219: https://github.com/balena-io-modules/balena-preload/pull/219/files#diff-72b1e00ac76f0313032875e2182181bbR673

cc: @thgreasi

thgreasi commented 4 years ago

Ends up that the balena-sdk instance that was injected was v13, and since v10 balena-preload bumped it's compatibility with the v6 model that balena-sdk v14 implements. See: https://www.flowdock.com/app/rulemotion/i-cli/threads/CxBdnZ9X2VeMOJDupNJqUnNyqeX