heroku / libcnb.rs

A framework for writing Cloud Native Buildpacks in Rust
BSD 3-Clause "New" or "Revised" License
35 stars 6 forks source link

Improve error message when env vars such as `CNB_TARGET_OS` are not set #803

Open edmorley opened 7 months ago

edmorley commented 7 months ago

In https://github.com/heroku/procfile-cnb/issues/214 the buildpack failed with the following error message:

step-build-and-push [Error: Internal Buildpack Error]
step-build-and-push Couldn't determine target os: environment variable not found
step-build-and-push err:  heroku/procfile@3.0.0 (1)
step-build-and-push ======== Output: heroku/procfile@3.0.0 ========

This was due to the CNB_TARGET_OS env var not being set correctly (when Buildpack API 0.10 says it should), however, we could improve the error message to include the env var name to make such scenarios easier to debug.

https://github.com/heroku/libcnb.rs/blob/f0983996fd4e8a0cf5bb916ed4608b731fb6474c/libcnb/src/error.rs#L26-L30