Commit 258dfa0
authored
Improve error messages and metrics for unhandled errors (#1933)
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.1 parent fc63f31 commit 258dfa0
4 files changed
Lines changed: 55 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
112 | 125 | | |
113 | 126 | | |
114 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments