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

Handling Authentication Errors in install_kustomize.sh` #5755

Open
viniciusdc opened this issue Sep 3, 2024 · 1 comment · May be fixed by #5756
Open

Handling Authentication Errors in install_kustomize.sh` #5755

viniciusdc opened this issue Sep 3, 2024 · 1 comment · May be fixed by #5756
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@viniciusdc
Copy link

What happened?

The install_kustomize.sh script is designed to download and install the kustomize binary. However, if a GITHUB_TOKEN is set in the environment but is invalid or expired, the script fails with authentication errors, such as Bad credentials.

{
  "message": "Bad credentials",
  "documentation_url": "https://docs.github.com/rest",
  "status": "401"
}

Currently, the script attempts to authenticate with GitHub using the GITHUB_TOKEN but does not handle cases where this token is incorrect or invalid, leading to confusing error messages like:

Version v5.4.3 does not exist or is not available for linux/amd64.

If the support for the token is expected in the installation script, extending the validation to consider such errors sounds reasonable. I assume this extra block would be enough, at least to give the end user some guidance (mostly when inspecting CI logs):

# Check for authentication errors
if [[ $releases == *"Bad credentials"* ]]; then
  echo "Authentication failed: Invalid GITHUB_TOKEN. Please check or remove your token."
  exit 1

if [[ $releases == *"API rate limit exceeded"* ]]; then
echo "Github rate-limiter failed the request. Either authenticate or wait a couple of minutes."
exit 1
fi

What did you expect to happen?

The script should handle authentication errors gracefully and provide a clear message indicating that there is an issue with the GITHUB_TOKEN.

How can we reproduce it (as minimally and precisely as possible)?

  1. Set an invalid or expired GITHUB_TOKEN in your environment.
  2. Run the install_kustomize.sh script locally passing a desired version:
    • bash install_kustomize.sh 5.4.3
  3. Observe the script's failure due to authentication errors from GitHub.

Expected output

downloaded binary

Actual output

Version v5.4.3 does not exist or is not available for linux/amd64.

Kustomize version

5.4.3

Operating system

Linux

@viniciusdc viniciusdc added the kind/bug Categorizes issue or PR as related to a bug. label Sep 3, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 3, 2024
@koba1t
Copy link
Member

koba1t commented Sep 4, 2024

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants