This repository was archived by the owner on Aug 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
This repository was archived by the owner on Aug 11, 2025. It is now read-only.
Incorrect LSP response when using map property lookup for resource id value #60
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Versions
This bug is reproducible in:
- the latest version of the extension (below)
- the latest version of the language server (below)
Extension
v1.0.0
Language Server
Starting terraform-ls v1.0.0
VS Code
1.72.2
Operating System
macOS 12.6
Terraform Version
Terraform v1.3.2
on darwin_arm64
Steps To Reproduce
Steps to reproduce the behavior:
(using v1.0.0 of provider)
Include any relevant Terraform configuration or project structure:
resource "azapi_resource" "peering_hub_outbound" {
for_each = { for k, v in var.virtual_networks : k => v if v.hub_peering_enabled }
type = "Microsoft.Network/virtualNetworks/virtualNetworkPeerings@2021-08-01"
parent_id = local.hub_peering_map[each.key]["outbound"].this_resource_id
name = local.hub_peering_map[each.key]["outbound"].name
body = jsonencode({
properties = {
remoteVirtualNetwork = {
# LSP error here!
id = local.hub_peering_map[each.key]["outbound"].remote_resource_id
}
allowVirtualNetworkAccess = true
allowForwardedTraffic = true
allowGatewayTransit = false
useRemoteGateways = each.value.hub_peering_use_remote_gateways
}
})
}lsp log:
2022/10/18 11:59:26 opts.go:252: Received request batch of size 1 (qlen=0)
2022/10/18 11:59:26 opts.go:252: Dequeued request batch of length 1 (qlen=0)
2022/10/18 11:59:26 rpc_logger.go:29: Incoming request for "textDocument/hover" (ID 325): {"textDocument":{"uri":"file:///Users/matt/code/terraform-azurerm-lz-vending/modules/virtualnetwork/main.tf"},"position":{"line":85,"character":64}}
2022/10/18 11:59:26 hover.go:39: Looking for hover data at "main.tf" -> hcl.Pos{Line:86, Column:65, Byte:3132}
2022/10/18 11:59:26 [WARN] expect value but got }
2022/10/18 11:59:26 [WARN] expect key but got [
2022/10/18 11:59:26 [WARN] expect value but got }
2022/10/18 11:59:26 hover.go:96: received allowed keys: []schema.Property{schema.Property{Name:"id", Description:"Resource ID.", Modifier:"Optional", Type:"string", Value:""}}
2022/10/18 11:59:26 hover.go:41: received hover data: &protocol.Hover{Contents:protocol.MarkupContent{Kind:"markdown", Value:"```\nid: Optional(string)\n```\nResource ID."}, Range:protocol.Range{Start:protocol.Position{Line:0x55, Character:0x39}, End:protocol.Position{Line:0x55, Character:0x4b}}}
2022/10/18 11:59:26 rpc_logger.go:50: Response to "textDocument/hover" (ID 325): {"contents":{"kind":"markdown","value":"```\nid: Optional(string)\n```\nResource ID."},"range":{"start":{"line":85,"character":57},"end":{"line":85,"character":75}}}
2022/10/18 11:59:26 opts.go:252: Completed 1 requests [44.941125ms elapsed]
Expected Behavior
LSP should accept that resource ID can be retrieved from any attribute of object
Actual Behavior
LSP required that supplied object has a .id property
Additional context
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
