Azure Pipeline Task Success - Packer Build Failure

Using Packer to create images in Azure that are placed into a Shared Image Gallery. The name of the managed image was mistyped, causing the build to fail as it couldn’t match an existing image definition. However the Azure DevOps Pipeline task was still successful.

Am I correct to understand that if Packer fails a build step but is able to successfully clean up the resources it had created, then packer exits with error code 0?

Are there any flags that can be used that may change this behavoir? So a failure step within a build causes packer to exit with error greater than zero.

I’m happy for the on-error action to be the default cleanup. In most cases, we would prefer the resources are cleaned given the costs that a failed image creation can incur.