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

Terraform LS 0.32.4 - tfe provider 0.51.0 - tfe_organization data source - LS not accounting for changes that occurred in this version #1523

Open
1 task
zisom-hc opened this issue Dec 18, 2023 · 3 comments
Labels
bug Something isn't working outdated-schema

Comments

@zisom-hc
Copy link

Language Server Version

v0.32.4

Terraform Version

1.6.6

Client Version

VS Code 1.85.0

Terraform Configuration

terraform {
  required_providers {
    tfe = {
      source  = "hashicorp/tfe"
      version = "~> 0.51.0"
    }
  }
}

data "tfe_organization" "test-company" {
}

Steps to Reproduce

  1. init version 0.51.0 of the tfe provider
  2. Configure a tfe_organization data source block without a name argument configured
  3. Observe the error that LS states

Expected Behavior

LS should recognize that in version 0.51.0 of the tfe provider, a change was made to this data source where the name argument went from being required to optional in tfe 0.51.0

d/tfe_organization: Make name argument optional if configured for the provider, by @tmatilai hashicorp/terraform-provider-tfe#1133

Actual Behavior

LS states: Required attribute "name" not specified: An attribute named "name" is required here

Gist

No response

Workarounds

You can perform a terraform plan/apply without issue, so the error is just misleading, not blocking operations from occurring.

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@zisom-hc zisom-hc added the bug Something isn't working label Dec 18, 2023
@radeksimko
Copy link
Member

Hi @zisom-hc
The mentioned attribute was added to the provider relatively recently, as you noticed.

Since we only bundle a single version of the tfe provider schema in the language server (just like for other official+partner providers), we cannot provide the level of accuracy out of the box at this point unfortunately. The latest version available at the time of the latest LS release was v0.50.0.

The good news is however that if you run terraform init to install the latest version of the provider (assuming you have the appropriate version constraint that matches 0.51.0 which you do), the extension will pick it up and use that schema to do the validation.

We plan to improve the experience in similar situations by eventually pulling the schema from the Registry API but this is a non-trivial project that will take some time to execute. You can follow hashicorp/vscode-terraform#737 in the meantime.

@zisom-hc
Copy link
Author

Hey Radek, thank you for the insight regarding this. That's understandable that the provider schema currently being used within the latest version of the LS is from 0.50.0 of the tfe provider. The purpose of this was to inform y'all of the current discrepancy between the two versions at the moment.

The good news is however that if you run terraform init to install the latest version of the provider (assuming you have the appropriate version constraint that matches 0.51.0 which you do), the extension will pick it up and use that schema to do the validation.

Do i understand correctly that you're saying that the LS should be grabbing the schema for 0.51.0 when i perform a terraform init within the working directory of my module? If that is the case, i am not seeing that behavior post-init, as in i'm still seeing the problem prompt exist, so let me know if the steps below were not correct:

  1. Opened module code within VS Code
  2. executed terraform init within the working directory
  3. Observe whether the problem prompt disappeared for the tfe_organization data source, which did not occur
  4. re-opened organization.tf in VS Code to see if the problem prompt would then go away, with no change to the result (This step

Here's a screenshot of what i'm seeing post-init:
image

@radeksimko
Copy link
Member

The purpose of this was to inform y'all of the current discrepancy between the two versions at the moment.

We appreciate it, although unfortunately this impacts users of all providers and it's not a problem isolated to tfe. Another example is in hashicorp/vscode-terraform#1621

Do i understand correctly that you're saying that the LS should be grabbing the schema for 0.51.0 when i perform a terraform init within the working directory of my module?

That's correct - this is how it should work.

There is however one extra step you have to take today, which is to either type into the file or re-open it. We plan to do this refresh automatically in the future - I have yet to file an issue for that.

See my recordings below

typing

2023-12-20 14 31 08

re-opening

2023-12-20 14 34 48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working outdated-schema
Projects
None yet
Development

No branches or pull requests

2 participants