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

Trying to download mentions_count as a version #2175

Closed
JeremieDoctrine opened this issue Dec 5, 2024 · 3 comments · Fixed by #2176
Closed

Trying to download mentions_count as a version #2175

JeremieDoctrine opened this issue Dec 5, 2024 · 3 comments · Fixed by #2176
Labels

Comments

@JeremieDoctrine
Copy link

JeremieDoctrine commented Dec 5, 2024

Summary

We are running tflint on many of our CI's

From time to time it fails installing with the following error:

====================================================
Looking up the latest version ...
Downloading TFLint mentions_count
curl: (22) The requested URL returned error: 404 

Exited with code exit status 22

We are installing tflint this way:

curl  --retry 3 -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | TFLINT_VERSION=latest bash

My guess is that this grep https://github.com/terraform-linters/tflint/blob/master/install_linux.sh#L46 is not catching the tag_name but another row. Not exactly sure why at the moment.

Downloading TFLint mentions_count seems totally wrong.

Command

TFLINT_VERSION=latest bash

Terraform Configuration

n/a

TFLint Configuration

n/a

Output

====================================================
Looking up the latest version ...
Downloading TFLint mentions_count
curl: (22) The requested URL returned error: 404 

Exited with code exit status 22


### TFLint Version

0.54.0

### Terraform Version

1.9

### Operating System

- [X] Linux
- [ ] macOS
- [ ] Windows
@bendrucker
Copy link
Member

This is really odd, surely there is some pattern? A specific release or version of the tools or something? I've tried querying the Github API and doing different things like deleting tag_name from the response and can't reproduce.

@JeremieDoctrine
Copy link
Author

JeremieDoctrine commented Dec 6, 2024

We haven't found any pattern and it's indeed very odd ... we are installing it the same way on all of our CI's.

One thing I was thinking about was about 403 ...

❯ curl  --retry 3 -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | TFLINT_VERSION=latest bash

arch=arm64
os=darwin_arm64


====================================================
Looking up the latest version ...
curl: (56) The requested URL returned error: 403

But it fails with a valid error message. We will try to add some logs on the install script and see.

@bendrucker
Copy link
Member

bendrucker commented Dec 6, 2024

Ah on a second pass I see how this is happening. It's no coincidence that mentions_count is the last key in the object.

This does reproduce:

curl --fail -Ss https://api.github.com/repos/terraform-linters/tflint/releases/latest | jq --compact-output | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
mentions_count

The script is newline dependent. Without newlines, grep just matches the single line of output and sed grabs the last quoted string, whether key or value. And jq --compact-output reproduces that.

Why this would be non-deterministic assuming it comes from GitHub is a mystery. But the script could definitely be written more robustly to not be newline-dependent. I'll make that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants