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

Incorrect LSP response when using map property lookup for resource id value #60

Open
2 tasks done
matt-FFFFFF opened this issue Oct 18, 2022 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@matt-FFFFFF
Copy link
Member

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
    }
  })
}

image

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

@matt-FFFFFF matt-FFFFFF added the bug Something isn't working label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant