Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apt-get/curl errors don't cause the buildpack to fail early #47

Closed
edmorley opened this issue Jun 10, 2019 · 1 comment · Fixed by #79
Closed

apt-get/curl errors don't cause the buildpack to fail early #47

edmorley opened this issue Jun 10, 2019 · 1 comment · Fixed by #79
Assignees
Labels

Comments

@edmorley
Copy link
Member

The buildpack pipes apt/curl commands to an indent helper, but unfortunately doesn't set the pipefail bash option, which means the exit code is ignored, so the buildpack doesn't fail early:

#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir>
# fail fast
set -e

See the set -o pipefail section on:
http://redsymbol.net/articles/unofficial-bash-strict-mode/

In addition, the curl usage doesn't pass -f, so won't return non-zero for non-HTTP-200 responses:

curl -s -L -z $PACKAGE_FILE -o $PACKAGE_FILE $PACKAGE 2>&1 | indent

Examples of both of these happening can be seen in the output in #45.

@edmorley
Copy link
Member Author

This came up again in https://heroku.support/953081. Have filed W-8722791 for tracking this internally.

@edmorley edmorley self-assigned this Jan 15, 2021
edmorley added a commit that referenced this issue Jan 15, 2021
Enables the bash `pipefail` mode, which ensures that a failure in a
command prior to a pipe correctly causes the script to exit 1.

Without this, failures during the `apt-get` and `curl` invocations were
ignored and the compile marked as a success. At best this leads to
confusing errors in later buildpacks (if build time dependencies are
missing), and at worst this could cause runtime failures for packages
not used during the build, but required by the app at runtime.

Enabling `pipefail` mode required a change to the custom repositories
feature, to prevent the build exiting 1 when `grep -s -e "^:repo:"`
found no matches (ie when no custom repositories are specified).

In addition, the `--show-error` and `--fail` flags have been added to
the `curl` call, otherwise non-HTTP 200 exit codes are ignored and the
compile similarly marked as successful when it should not have been.

Fixes #47.
Fixes W-8722791.
edmorley added a commit that referenced this issue Jan 15, 2021
Enables the bash `pipefail` mode, which ensures that a failure in a
command prior to a pipe correctly causes the script to exit 1.

Without this, failures during the `apt-get` and `curl` invocations were
ignored and the compile marked as a success. At best this leads to
confusing errors in later buildpacks (if build time dependencies are
missing), and at worst this could cause runtime failures for packages
not used during the build, but required by the app at runtime.

Enabling `pipefail` mode required a change to the custom repositories
feature, to prevent the build exiting 1 when `grep -s -e "^:repo:"`
found no matches (ie when no custom repositories are specified).

In addition, the `--show-error` and `--fail` flags have been added to
the `curl` call, otherwise non-HTTP 200 exit codes are ignored and the
compile similarly marked as successful when it should not have been.

Fixes #47.
Fixes W-8722791.
EtienneM referenced this issue in Scalingo/apt-buildpack Dec 16, 2022
Enables the bash `pipefail` mode, which ensures that a failure in a
command prior to a pipe correctly causes the script to exit 1.

Without this, failures during the `apt-get` and `curl` invocations were
ignored and the compile marked as a success. At best this leads to
confusing errors in later buildpacks (if build time dependencies are
missing), and at worst this could cause runtime failures for packages
not used during the build, but required by the app at runtime.

Enabling `pipefail` mode required a change to the custom repositories
feature, to prevent the build exiting 1 when `grep -s -e "^:repo:"`
found no matches (ie when no custom repositories are specified).

In addition, the `--show-error` and `--fail` flags have been added to
the `curl` call, otherwise non-HTTP 200 exit codes are ignored and the
compile similarly marked as successful when it should not have been.

Fixes #47.
Fixes W-8722791.
Frzk referenced this issue in Scalingo/apt-buildpack May 13, 2024
Enables the bash `pipefail` mode, which ensures that a failure in a
command prior to a pipe correctly causes the script to exit 1.

Without this, failures during the `apt-get` and `curl` invocations were
ignored and the compile marked as a success. At best this leads to
confusing errors in later buildpacks (if build time dependencies are
missing), and at worst this could cause runtime failures for packages
not used during the build, but required by the app at runtime.

Enabling `pipefail` mode required a change to the custom repositories
feature, to prevent the build exiting 1 when `grep -s -e "^:repo:"`
found no matches (ie when no custom repositories are specified).

In addition, the `--show-error` and `--fail` flags have been added to
the `curl` call, otherwise non-HTTP 200 exit codes are ignored and the
compile similarly marked as successful when it should not have been.

Fixes #47.
Fixes W-8722791.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant