balena-io / balena-cli

The official balena CLI tool.
Apache License 2.0
453 stars 139 forks source link

preload: Javascript error loading image list (introduced in 16.7.9) #2677

Closed deregtd closed 1 year ago

deregtd commented 1 year ago

Expected Behavior

Expecting preloader to not crash on newer versions of balena-cli

Actual Behavior

There is a regression introduced in 16.7.9 -- I checked 17.1.1, 16.8.0, 16.7.9, and 16.7.8, and it works in 16.7.8 and fails in 16.7.9 and above. Here is the 16.7.9 patch notes:

Update balena-sdk from 17.21.1 to 18.0.0
Update balena-preload from 14.0.0 to 14.0.2
Update balena-image-manager from 9.0.0 to 9.0.2

Here's a simplified log from my runner:

[debug] new argv=[/home/runner/.asdf/installs/balena-cli/16.7.9/balena-cli/balena,/snapshot/balena-cli/bin/balena,preload,.images/raspberrypi4-64_4.0.7_dev.img,-f,[project],--commit,[hash],--pin-device-to-release] length=9

Building Docker preloader image. [                        ] 0%

Building Docker preloader image. [===                     ] 12%
Step 1/7 : FROM alpine:3.12
 ---> 24c8ece58a1a

Building Docker preloader image. [======                  ] 25%
Step 2/7 : WORKDIR /usr/src/app
 ---> Running in 87423ed4f433
Removing intermediate container 87423ed4f433
 ---> 995b674887d1

Step 3/7 : RUN apk add --no-cache curl py3-pip parted btrfs-progs util-linux sfdisk file coreutils sgdisk e2fsprogs-extra docker
Building Docker preloader image. [=========               ] 37%
 ---> Running in 06282ece510e
[installs a bunch of crap]
Removing intermediate container 06282ece510e

Building Docker preloader image. [============            ] 50%
 ---> 6a0da5faf0b6
Step 4/7 : COPY requirements.txt ./
 ---> 3be5ec17862f
Step 5/7 : RUN pip3 install --no-cache-dir -r requirements.txt

Building Docker preloader image. [===============         ] 62%
 ---> Running in 72f8e762ef5e
[installs some more crap]
Removing intermediate container 72f8e762ef5e

 ---> 0c9174527242
Building Docker preloader image. [==================      ] 75%
Step 6/7 : COPY src/ ./
 ---> a763aeeeef37

Building Docker preloader image. [=====================   ] 87%
Step 7/7 : CMD ["python3", "/usr/src/app/preload.py"]
 ---> Running in a8cd17d21537
Removing intermediate container a8cd17d21537
 ---> f35edecb85e5
Successfully built f35edecb85e5
Successfully tagged balena/balena-preload:latest

Building Docker preloader image. [========================] 100%

Waiting for Docker to start...
Docker started

Cannot read properties of undefined (reading 'split')

TypeError: Cannot read properties of undefined (reading 'split')
    at Preloader._getImagesToPreload (/snapshot/balena-cli/node_modules/balena-preload/build/preload.js:397:66)
    at Preloader._ensureCanPreload (/snapshot/balena-cli/node_modules/balena-preload/build/preload.js:669:18)
    at /snapshot/balena-cli/node_modules/balena-preload/build/preload.js:701:18
From previous event:
    at processImmediate (node:internal/timers:466:21)
From previous event:
    at Preloader.preload (/snapshot/balena-cli/node_modules/balena-preload/build/preload.js:700:51)
    at PreloadCmd.prepareAndPreload (/snapshot/balena-cli/build/commands/preload.js:320:25)
    at async PreloadCmd.run (/snapshot/balena-cli/build/commands/preload.js:[127](https://github.com/boatkit-io/goatkit/actions/runs/6218328247/job/16874683216?pr=130#step:7:128):13)
    at async PreloadCmd._run (/snapshot/balena-cli/node_modules/@oclif/command/lib/command.js:43:20)
    at async Config.runCommand (/snapshot/balena-cli/node_modules/@oclif/config/lib/config.js:[175](https://github.com/boatkit-io/goatkit/actions/runs/6218328247/job/16874683216?pr=130#step:7:176):24)
    at async CustomMain.run (/snapshot/balena-cli/node_modules/@oclif/command/lib/main.js:28:9)
    at async CustomMain._run (/snapshot/balena-cli/node_modules/@oclif/command/lib/command.js:43:20)
    at async /snapshot/balena-cli/build/app.js:76:13
    at async Promise.all (index 2)
    at async oclifRun (/snapshot/balena-cli/build/app.js:94:5)
    at async Object.run (/snapshot/balena-cli/build/app.js:107:9)
    at async run (/snapshot/balena-cli/bin/balena:20:2)

Steps to Reproduce the Problem

The above is a log of the input and output. The project is a private project, so unfortunately I can't open source a full repro.

Specifications

otaviojacobi commented 1 year ago

Hello @deregtd thanks for raising. I have checked it and managed to reproduce. This problem only occurs when a commit hash is passed. A fix has been implemented in https://github.com/balena-io-modules/balena-preload/pull/285 and should be deployed by tomorrow.

otaviojacobi commented 1 year ago

Hello @deregtd a fix has been deployed in release version 17.1.2 Can you please retry with it and let us know if your problem has been fixed?

deregtd commented 1 year ago

Worked great, thanks much for the quick fix and keeping me up to date on the release!