Conversation
Adds a Bash ERR trap to catch any unhandled buildpack errors, which
displays a more helpful error message (that includes the command being
run and the stack trace), as well as setting an appropriate failure
reason and detail in the build event payload.
For example:
```
-----> Using Python 3.13 specified in .python-version
-----> Installing Python 3.13.8
mkdir: cannot create directory ‘/tmp/build_1/.heroku’: Not a directory
! Internal Error: An unhandled buildpack error occurred.
!
! An unhandled error occurred while executing the command:
! mkdir -p "${install_dir}"
!
! If this issue persists, please open a support ticket or file
! an issue on the buildpack's GitHub repository:
! https://help.heroku.com/
! https://github.com/heroku/heroku-buildpack-python/issues
!
! Stack trace:
! python::install @ /tmp/buildpack/lib/python.sh:25
! main @ ./bin/compile:170
~ Report:
{
...
"failure_detail": "mkdir -p \"${install_dir}\"",
"failure_reason": "internal-error::unhandled",
...
}
```
See:
- https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#index-trap
- https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html#index-caller
- https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html
- https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
GUS-W-19792272.
GUS-W-19792285.
dzuelke
approved these changes
Oct 14, 2025
Contributor
dzuelke
left a comment
There was a problem hiding this comment.
Cool, I like this approach, especially since we discussed this several times and both went back and forth on it and you finally picked an approach ;)
I think capturing the failed command as failure_reason and keeping the trace in the printed message is a good compromise, probably easier to see patterns this way in the data (as opposed to trying to group by a "normalized" trace where line numbers may vary over time).
Merged
edmorley
added a commit
that referenced
this pull request
Oct 15, 2025
Since: - The underlying cause of the errors (a bug in older `ensurepip`) was fixed in #1761 and friends. - As of #1933 the generic error trap now handles all internal errors, meaning we don't custom handling for them any more. GUS-W-19898848.
edmorley
added a commit
that referenced
this pull request
Oct 15, 2025
Since: - The underlying cause of the errors (a bug in older `ensurepip`) was fixed in #1761 and friends. - As of #1933 the generic error trap now handles all internal errors, meaning we don't custom handling for them any more. GUS-W-19898848.
edmorley
added a commit
that referenced
this pull request
Oct 15, 2025
Since: - The underlying cause of the errors (a bug in older `ensurepip`) was fixed in #1761 and friends. - As of #1933 the generic error trap now handles all internal errors, meaning we don't custom handling for them any more. GUS-W-19898848.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Bash ERR trap to catch any unhandled buildpack errors, which displays a more helpful error message (that includes the command being run and the stack trace), as well as setting an appropriate failure reason and detail in the build event payload.
For example:
See:
GUS-W-19792272.
GUS-W-19792285.