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

Prevent silent fail #104

Open
MohammedAl-Mahdawi opened this issue Jan 26, 2022 · 4 comments
Open

Prevent silent fail #104

MohammedAl-Mahdawi opened this issue Jan 26, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@MohammedAl-Mahdawi
Copy link

Hi!,

We are using this command in our CI/CD pipeline:

fetch --repo="https://github.com/..." --tag="1.0.9" --github-oauth-token="****" --release-asset="example-v1.0.9.zip" tmp-path

Yesterday this command fails because of a GitHub authorization error, however, it only logs the error instead of exiting with non-zero code this causes the pipeline to continue then exist on another step that depends on what has been downloaded by fetch.

Please we need an option to exit on error.

@MohammedAl-Mahdawi MohammedAl-Mahdawi added the enhancement New feature or request label Jan 26, 2022
@denis256
Copy link
Member

Hi,
I was trying to check this issue, however, on the last version exit code is 1 in case of an error:

$ fetch --repo="https://github.com/gruntwork-io/terraform-aws-ci" --tag="v0.41.1" --github-oauth-token="***" --release-asset "infrastructure-deployer_linux_386" tmp-path
[fetch] ERRO[2022-01-26T23:21:59+02:00] 
Received an HTTP 401 Response when attempting to query the repo for its tags.

This means that either your GitHub oAuth Token is invalid, or that the token is valid but is being used to request access
to either a public repo or a private repo to which you don't have access.

Underlying error message:
Received HTTP Response 401 while fetching releases for GitHub URL https://api.github.com/repos/gruntwork-io/terraform-aws-ci/tags?per_page=100. Full HTTP response: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}

$ echo $?
1

On which version occurred this issue?

@MohammedAl-Mahdawi
Copy link
Author

Hi!

Thank you for the quick reply!

We are using v0.4.2

I read the release notes of version v0.4.3 before posting this and did not found anything related.

So it has been fixed in the new release?

@denis256
Copy link
Member

Hi, so from the above message, in my test exit code wasn't 0 in case of failure:

...
$ echo $?
1

Exiting with non-zero code is already implemented, may be an issue with code which call fetch that is not handling error code? like missing set -euxo pipefail?

@MohammedAl-Mahdawi
Copy link
Author

Hi!

Weird, I believe the commands in pipeline steps get wrapped in #!/usr/bin/env bash and executed.

We are using it as a step alone so it is executed like this:

#!/usr/bin/env bash

fetch --repo="https://github.com/..." --tag="1.0.9" --github-oauth-token="****" --release-asset="example-v1.0.9.zip" tmp-path

But everything works fine with other commands/steps!

What makes things weirder, I just tried to reproduce the issue and this time it exited with a non-zero code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants