heroku / buildpacks-nodejs

Heroku's Cloud Native Buildpacks for Node.js applications.
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

`heroku/nodejs-npm-install` is erroring instead of gracefully failing detection, causing log spam #722

Closed edmorley closed 11 months ago

edmorley commented 11 months ago

The heroku/nodejs-npm-install buildpack is currently erroring if a package.json is not found, rather than gracefully "failing" detect.

For example:

======== Output: heroku/nodejs-npm-install@2.3.0 ========
- Debug info
  - No such file or directory (os error 2)

! Error reading `package.json`.
!
! This buildpack requires `package.json` to complete the build but the file can’t be read. 
!
! Use the debug information above to troubleshoot and retry your build.
!
! If the issue persists and you think you found a bug in the buildpack then reproduce the issue locally with a minimal example and open an issue in the buildpack's GitHub repository with the details.

err:  heroku/nodejs-npm-install@2.3.0 (1)

From: https://github.com/heroku/cnb-builder-images/actions/runs/6870978876/job/18686993769#step:6:10

edmorley commented 11 months ago

The text of the current error message needs to be moved to an info level logger call, and then detect needs to return DetectResultBuilder::fail().build() not an Err.

The tests in this repo ideally would also be updated to catch this.

Python's implementation for reference: https://github.com/heroku/buildpacks-python/blob/eed94d4e6214232d7cef3b85785bc71a9609e7c9/src/main.rs#L45-L50 https://github.com/heroku/buildpacks-python/blob/eed94d4e6214232d7cef3b85785bc71a9609e7c9/tests/detect_test.rs#L7-L21

edmorley commented 11 months ago

cc @colincasey @joshwlewis