'string field contains invalid UTF-8' error

I have the following trivial example which keeps giving me an error about an invalid UTF-8 character. I’ve been able to reproduce it with a completely new file, I’ve tried overtyping the offending area, looking over it with a hex editor but I’ve got nothing. It passes validation but errors in plan, enabling debug doesn’t give any more information.

provider "azurerm" {
  features {}
}
# Adding this gives 'string field contains invalid UTF-8' error
resource "azurerm_resource_group" "rg" {
  name     = "rg"
  location = "uksouth"
}

Hi @TerraErr0r,

Could you share the full error message exactly as Terraform printed it? I’d like to see what exactly the error message was referring to here, since copy-pasting into the forum has probably changed the details of exactly how your file is encoded.

If you see something underlined in the source code snippet Terraform prints out then it would be helpful to mention which part is underlined too, since that won’t come across in copy-paste but it could help narrow down exactly what part of your input Terraform’s parser is objecting to.