Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preload: TypeError: Cannot destructure property __id of 'undefined' or 'null' #2335

Open
pdcastro opened this issue Sep 14, 2021 · 0 comments

Comments

@pdcastro
Copy link
Contributor

When the balena preload command is used with an application that has no successful releases, an unhelpful / unhandled error is produced:

balena preload balena-fin-image.img --app fin_support --commit latest --debug
-------------------------------------------------------------------------------
[Warn] Renaming notice: The '-a', '--app' or '--application' options are now
[Warn] aliases for the '-f' or '--fleet' options. THE ALIASES WILL BE REMOVED
[Warn] in the next major version of the balena CLI (so that a different '--app'
[Warn] option can be implemented in the future). Use '-f' or '--fleet' instead.
[Warn] Find out more at: https://git.io/JRuZr
-------------------------------------------------------------------------------
Building Docker preloader image. [========================] 100%
| Checking that the image is a writable file
| Finding a free tcp port
| Checking if the image is an edison zip archive
\ Creating preloader container
\ Starting preloader container
| Fetching application g_alex_gonzalez2/fin_support
\ Cleaning up temporary files
| Reading image information
Cannot destructure property `__id` of 'undefined' or 'null'.

TypeError: Cannot destructure property `__id` of 'undefined' or 'null'.
    at _fetchApplication._runWithSpinner (/snapshot/versioned-source/node_modules/balena-preload/build/preload.js:566:25)
    at process._tickCallback (internal/process/next_tick.js:68:7)
From previous event:
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:126:23)
From previous event:
    at Preloader.prepare (/snapshot/versioned-source/node_modules/balena-preload/build/preload.js:621:48)
    at PreloadCmd.prepareAndPreload (/snapshot/versioned-source/build/commands/preload.js:296:25)
    at run.Promise (/snapshot/versioned-source/build/commands/preload.js:133:30)
    at new Promise (<anonymous>)
    at PreloadCmd.run (/snapshot/versioned-source/build/commands/preload.js:131:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)

It is not possible and/or does not make sense to attempt to preload an inexistent or unsuccessful release (a release for which services images failed to build), but this error can happen when a newly created application is selected by mistake, and it causes confusion. A nicer error message should be printed instead, e.g. "Application does not have any successful releases." This could be implemented in the _fetchApplication() function, around the following line of code:
https://github.com/balena-io-modules/balena-preload/blob/v10.5.0/lib/preload.js#L767

Originally reported by @alexgg in an FD thread (restricted access), using CLI v12.48.12. cc: @klutchell

Workaround

Select a different application that has successful releases, or push a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant