Ghost custom theme error while uploading: Validation error

I just updated to Ghost 4.9 and my custom theme stopped working. The page started to throw 500 errors and I had to switch back to Casper. When I try to switch back to my theme the API returns a 400.

When I try to upload a new zip with the theme it fails saying “Fail to read zip file”.

When I upload it to Gscan it throws this error:

Cannot read property 'join' of undefined

ValidationError: Failed to read zip file at new ValidationError (/app/node_modules/ghost-ignition/lib/errors/index.js:141:23) at /app/lib/index.js:34:19

I have searched this and it seems to be a problem with the permissions on the zip file with gulp-zip and Windows? But my build process uses the system zip command on macOS Big Sur. Basically this:

zip -vr dist/my_theme.zip ./ -x '*.DS_Store' -x '*dist*' -x '*.git*' -x '*node_modules*' 

I really don’t know what’s going on. I have Ubuntu v18.04.5 LTS on a DigitalOcean machine with node v12.22.2 and ghost-cli 1.17.3.

For now I’m going back to 4.8.1. I did ghost update --rollback and everything works again.

You’re not the only one. Upon updating (from 4.8.4) I also got the 500 error (which also stated something like “Can’t read theme” or “Can’t find theme”, I forget). I too switched to Casper, which worked, and when I tried to switch back over to the theme that apparently didn’t work the Activate button was unresponsive. So I deleted the theme and tried re-uploading it, which is when I got that “Fail to read zip file” message as well. I tried uploading an entirely different theme, which worked fine. Gscan gave me the same error message as you got when trying to validate the non-uploadable theme:

Your idea that it might be related to Gulp could very well make sense, seeing how that non-uploadable theme of mine utilises Gulp, while the theme that did manage to upload is not using Gulp.

Hey @bop @Stromfeldt can you please get a more detailed logs from your instances when the error happens?

The Cannot read property 'join' of undefined is a useful clue. Would need to get a stacktrace from the error to find out exactly where it’s happening. Given your themes are private, would be good to find out which piece of code in your themes causes this error, so we could have a reproducible example. Thanks!

@naz Thanks for reply! Luckily I just saw the commits for 4.9.2 and I can confirm that the new release fixes the bug. Everything is working fine now and I’m fully updated!

Not sure if this is the same issue, but I’m getting a ‘name is not defined’ error when uploading a theme. It’s pretty weird, since I get the same error even when I download the current theme and re-upload it (without any changes).

Hosted w/ Ghost Pro on what I believe is the latest up-to-date instance.

Hey @justinv. That error has been fixed in the latest patch release:

Awesome, thanks so much @naz! This fixed it for me.