Select to view content in your preferred language

Experience Builder Automated Deployment should throw an error when ZipApp fails

347
1
03-24-2025 06:38 PM
Status: Open
Labels (3)
RyanTaylor
Occasional Contributor

For reference, see the Automated Deployment guidance documentation. In it, we're instructed to run

node -e "require('./server/src/middlewares/dev/apps/app-download.js').zipApp('0', 'app.zip', 'my_client_id');"

to download our zip. 

This works well enough in the ideal case. However, when zipApp fails we are left with nothing but error messages in stderr to indicate the failure. It would be helpful for our automated systems if zipApp would either: (1) exit with a non-zero exit code (2) return a non-zero number or (3), throw an error we can catch via try/catch.

My preference would be on #1 so we can easily check the error code in shells like cmd/PowerShell/bash.

I have a workaround in PowerShell that's rather ugly (↴). If a non-zero exit-code were returned I could simply call the function as described in the docs and the build would fail appropriately.

$ErrorActionPreference = $Stop
$PSNativeCommandUseErrorActionPreference = $true

if (Test-Path err.txt) { Remove-Item err.txt -Force }

node -e "require('./server/src/middlewares/dev/apps/app-download.js').zipApp('0', '$AppZip', '$ClientId');" 2>err.txt
    
$err = Get-Content err.txt -Raw
if ($err.Length -gt 0) {
    Write-Host "ZipApp failed with an unhandled exception ↴"
    throw $err
}

If others have found cleaner solutions, I would love to hear them.

1 Comment
TianWen

Thanks for your post! We will consider adding more detailed error messages and will keep you updated.