netlify / build-image

This is the build image used for running automated builds
MIT License
496 stars 197 forks source link

Show an understandable error when `getBuildInfo` failed #898

Open sapphi-red opened 1 year ago

sapphi-red commented 1 year ago

Is your feature request related to a problem? Please describe.

When getBuildInfo throwed an error, it doesn't show any understandable error and continues the build (and the build fails). https://github.com/netlify/build-image/blob/3449ee7faac83f7ff90ab53658f6a5deaad21b63/tests/get-build-info.mjs#L4

The only error to notice getBuildInfo failed is:

jq: error (at :1): Cannot iterate over null (null)

Describe the solution you'd like

Show the error thrown from getBuildInfo and stop the build.

Describe alternatives you've considered

Make @netlify/build-info resilient to errors.

Additional context

Reproduction: https://github.com/sapphi-red-repros/netlify-pnpm-cannot-iterate-over-repro Build log: https://app.netlify.com/sites/dashing-marzipan-db6e0f/deploys/63ca28d308f3e100098fe2eb#L30

Running getBuildInfo in this reproduction will cause the following error:

Error: must not have multiple workspaces with the same name
package 'duplicated' has conflicts in the following paths:
    [...omit...]\netlify-pnpm-cannot-iterate-over-repro\packages\bar1\duplicated
    [...omit...]\netlify-pnpm-cannot-iterate-over-repro\packages\bar2\duplicated

Can you submit a pull request?

No.

Pull requests are welcome! If you would like to help us add this feature, please check our contributions guidelines.