-
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
"Unexpected attribute" false alarms #1681
Comments
+1, very annoying issue |
Weird that it's happening only on the aws vpc module, any idea why? |
It does also happen with the google vpc module (this is with v2.29.4) |
AWS EKS module also. |
Running VS Code on PopOS 22 and then Remote-SSH Plugin to Ubuntu 22.04.03 machine. Terraform v1.7.3 installed on that machine if it matters. Did try |
macOS for me (M1 chip), Terraform v1.7.3 |
So I've just opened that repo up for the first time in a week and now the error has gone. The Hashicorp tf extension is the same version, i.e. But the VS Code Version is now |
Experiencing the same as @jmcmillan1873 now, seems to have gone away after VS Code update. |
I'm still experiencing this and both the extension and VS Code are fully to up date. It will go away if I reload the window but will inevitably return, seemingly once it has finished walking all the files in the workspace. Edit: Removing the Extension: v2.29.4 VS Code: Terraform: v1.7.3 (this doesn't seem to make a difference, also happened on 1.6.2) I captured this from the output when I hovered over a line: 2024/02/22 09:08:42 rpc_logger.go:32: Incoming request for "textDocument/hover" (ID 51): {"textDocument":{"uri":"file:///Users/henworth/code/terraform/aws/us-east-1/vpc/main.tf"},"position":{"line":98,"character":22}}
2024/02/22 09:08:42 provider_schema.go:306: PSS: getting provider schema (/Users/henworth/code/terraform/aws/us-east-1/vpc, registry.terraform.io/hashicorp/aws, ~> 5.0)
2024/02/22 09:08:42 hover.go:35: Looking for hover data at "main.tf" -> hcl.Pos{Line:99, Column:23, Byte:2167}
2024/02/22 09:08:42 hover.go:37: received hover data: (*lang.HoverData)(nil)
2024/02/22 09:08:42 rpc_logger.go:48: Error for "textDocument/hover" (ID 51): [-32098] main.tf (99,23): unknown attribute "default_security_group_ingress"
2024/02/22 09:08:42 opts.go:215: Completed 1 requests [10.762625ms elapsed]
[Error - 9:08:42 AM] Request textDocument/hover failed.
Message: main.tf (99,23): unknown attribute "default_security_group_ingress"
Code: -32098 I've also attached an attempt to capture all relevant output once startup finishes post window reload, right when it marks the file as having errored lines. |
Note to self (or anyone else picking this up): I was able to accidentally reproduce the problem while investigating something else. It looks like when the registry request fails with a timeout (other errors seem fine), we are making incorrect assumptions about the module schema.
|
Also happen in resource resource "aws_kinesis_firehose_delivery_stream" "cdc" {
name = "${local.project}-${local.workspace}"
destination = "extended_s3"
extended_s3_configuration {
# ...
custom_time_zone = "Europe/Paris"
# ...
}
}
} |
I'm seeing this with "terraform-google-modules/network/google" as well. It seems like repos with both a top-level module and submodules are where it fails. I have a file where I use both the |
For me, I get the errors showing up with this module source: But they go away if I get rid of the double forward slash: However the latter doesn't work in terraform. Just thought this might help with reproducing it? |
Having the same error with an AWS resource Logged into remote SSH host: Version: 1.87.2 (user setup) Terraform 1.7.5 on Amazon Linux 2023 x86_64. |
I see the same issue with locals that are defined in a different .tf file |
How is the code getting what attributes are expected with each resources? Because that can vary depending on the provider versions, which are different per project. You're going to get a lot of wrong behavior if you hardcode that for a particular provider particular attributes are expected. |
Hi @borrell, this sounds like a different issue. Would you mind creating a new one with more details?
Hi @TinaHeiligers, this sounds like a different issue. Would you mind creating a new one with more details?
Hi @paul-civitas, we bundle the latest provider schema with the language server at build time to provide a better out-of-the-box experience. If a user has Terraform installed and has run For modules, we can get the schema from the registry, which should always ensure a matching version. Here it looks like there is an edge case when fetching module schemas on an unstable connection. |
@dbanck my issue turned out not to be a problem, my workspace was old |
Hey @dbanck that's EXACTLY the issue. That's why I think this is coming up.
It seems the schema of the locally installed provider doesn't get picked up sometimes, which leads to the issue I'm experiencing. It's not very clear in the extension when it's using a baked in schema and when it's using one from the locally installed provider. |
After this information I found the autodetect schema is assuming you are working in a single project. I have a folder with multiple projects and the modules folder. The extension reads the first folder with If I specify the provider version in the module folder the false alarms disappear. terraform {
required_version = ">= 1.3"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">=5.40"
}
}
} Hope this helps. |
Ahh yes this tracks with my use case. My workspace probably has 100 or so git repos in it. And some portion of them have terraform. Each one has a terraform version configured using asdf and its own settings on provider and provider versions. I understand if the maintainers want to focus on a single terraform repo with terraform per workspace, and a single terraform version that's set globally. But unfortunately that doesn't always reflect the reality of production codebases. |
still happening on 2.29.5 (using terraform-aws-lambda module). |
I wasn't able to reproduce this, it happened again and the only solution that seems to resolve it; even if temporarily; is to reload the window. Are there any logs or different modes to run this which may help provide additional information / context? |
I have the same issue. When renaming the tfvars file, the problem disappears. When adding another value to tfvars file, the problem occurs again. Very annoying issue EDIT: For me this error seemed to be happening when having the HashiCorp Terraform extension and the Terraform Advanced Syntax Highlighting extension enabled at the same time in vscode. So, I turned off the latter. |
FWIW the issue disappeared when I removed the |
For me it seems to trigger when I use version constraints instead of specific versions.
|
had the same issue on GCP, restarted the HashiCorp Terraform extension on VS code and the error is gone. |
❌ It was also happening to me while using
Terraform Version: 1.7.4 ✅ Updated to TF version |
i want to add a comment for the people that cannot apply @isaac-gomez-azumo solution. |
Extension Version
v2.29.3
VS Code Version
Version: 1.85.2 (user setup)
Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681
Date: 2024-01-18T06:40:10.514Z
Electron: 25.9.7
ElectronBuildId: 26354273
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22621
Operating System
Edition Windows 11 Enterprise Version 22H2 Installed on 13/12/2023 OS build 22621.3007 Experience Windows Feature Experience Pack 1000.22681.1000.0
Terraform Version
Terraform v1.7.1 on windows_amd64 + provider registry.terraform.io/hashicorp/aws v5.32.1
Steps to Reproduce
Expected Behavior
I don't expect the Hashicorp terraform extension to highlight the above code as having any 'problems'.
Actual Behavior
Unexpected attribute: An attribute named "name" is not expected here Terraform
The parameters that are highlighted as problems are all valid according to the Inputs section of the VPC module documentation. Also performing
terraform validate
on the command line confirms that the code is fine.Finally - and this is difficult to reproduce as it's not consistent - hovering over the highlighted problems in the code mostly shows the error:
Unexpected attribute: An attribute named "name" is not expected here Terraform.
However, occasionally it simultaneously display the 'unexpected' error as well as 'usage' message for the parameter it says should be there. See the attached image.
Terraform Configuration
No response
Project Structure
No response
Gist
No response
Anything Else?
The AWS toolkit extension was enable when I first encountered this issue.
I disabled the AWS extension and reloaded - so no other extensions were enabled during my steps to reproduce for this report.
Workarounds
None.
References
No response
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: