Skip to content

New Code Action: Resolve unexpected attribute #1562

Open
@radeksimko

Description

@radeksimko

Background

We currently report the following configuration as invalid:

terraform {
  foobar = "value"
}

There can be multiple reasons for unknown attribute:

  • too old/new schema we use for validation
  • typo
  • some hallucinated code generated by AI

It may be difficult to find the best solution if we don't know or can't guess the reason. Removing an attribute is a solution relevant in some contexts and not others.

Proposal

  • Consider providing quick fix code action which resolves the above diagnostic by removing the attribute

Further Thoughts

It may be worth looking at how the LS could guess the reason and provide more helpful quick fixes.

For example:

  • we could compare the attribute name with valid attribute names more loosely, just like Terraform Core does in its didyoumean package, so that we can suggest correction from e.g. reqired_version to required_version etc.
  • attempt to compare attribute names with other versions of the provider schema

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions