Open
Description
Background
We currently report the following configuration as invalid:
terraform {
my_block {
}
}
There can be multiple reasons for an unknown block:
- 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 a block 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 block
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 block name with valid block names more loosely, just like Terraform Core does in its
didyoumean
package, so that we can suggest correction from e.g.terrafrom {}
toterraform {}
etc. - attempt to compare block names with other versions of the provider schema