-
Notifications
You must be signed in to change notification settings - Fork 180
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
Syntax validation throwing incorrect errors for Terraform Test files (*.tftest.hcl
)
#1783
Comments
Hi @novekm! Sorry, the VS Code extension and language server don't support Terraform test files today. We are tracking this work in #1534. By default, the extension ignores You can check (and change) the language ID in the bottom right corner. It should be Hope this helps! Let me know if it solves your problem. |
Thanks @dbanck! I've downloaded the extension you mentioned and have now manually changed the language ID to |
Can you please check if your VS Code configuration contains any manual file associations? {
"files.associations": {
...
}
} |
Hi @dbanck, it looks like this one is set:
I don't recall setting this manually. Should this be removed? |
Yes! This can be removed and should solve your issue |
Thanks! I commented out those lines and it looks like the syntax validation errors are gone. I'll keep tracking #1534 to see when this is eventually added to Terraform. Thanks again! |
That's great to hear! Closing this for now. Feel free to open a new issue if something else comes up. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Extension Version
v2.30.2
VS Code Version
Version: 1.90.0 (Universal)
Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573
Date: 2024-06-04T19:34:44.157Z
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0
Operating System
macOS Sonoma Version 14.5
Terraform Version
Terraform v1.8.2
Steps to Reproduce
*.tftest.hcl
run
blockExpected Behavior
Syntax validation works properly
Actual Behavior
Receive validation error "Blocks of type "run" are not expected here. which is incorrect, as run blocks should be included in test files. So far I've been just ignoring it since it's an incorrect error, but it's a bit annoying and can make troubleshooting more difficult. This issue has persisted for multiple Terraform versions and multiple macOS versions in my testing.
What's odd is that if you quit and re-open VSCode, there is no error until you make any changes in files. Then the incorrect errors appear again. Only way to temporarily resolve is to quit and re-open VSCode, but the issue will continue to reappear.
Terraform Configuration
Project Structure
├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE.txt ├── README.md ├── VERSION ├── data.tf ├── examples │ ├── basic │ ├── create-users-and-groups │ ├── existing-users-and-groups │ ├── google-workspace │ └── inline-policy ├── locals.tf ├── main.tf ├── outputs.tf ├── providers.tf ├── test │ ├── go.mod │ ├── go.sum │ └── main_test.go ├── tests │ └── 01_mandatory.tftest.hcl ├── tf.json ├── tf.plan └── variables.tf
Gist
No response
Anything Else?
No response
Workarounds
If you quit and re-open VSCode, there is no error until you make any changes in files. Then the incorrect errors appear again. Only way to temporarily resolve is to quit and re-open VSCode, but the issue will continue to reappear.
References
No response
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: