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
Simple terraform script always causes grpc: error while marshaling: string field contains invalid UTF-8 #17563
Comments
Hi @xx364! I'm not a maintainer of this provider so I'm just commenting here with some hopefully-helpful additional context from the perspective of Terraform Core and the provider plugin protocol. This one is a bit puzzling to me because it seems to be originating in the guts of the gRPC client or server. The trace log seems to suggest that the request is at least making it into our own SDK codepaths, since we can see it reach a log line in However, the only string values in the All of this then has led me to wonder if there are circumstances where the Azure provider might return a diagnostic message whose summary or detail contains non-UTF-8 bytes, which none of our SDK layers catch but which get ultimately rejected by the protobuf codec before getting sent over the wire. Or maybe it is echoing back verbatim some error text generated by the underlying Azure SDK that itself isn't valid UTF-8? That was as far as I was able to delve with the codebases I'm familiar with. I hope it's useful in further investigation! (I wonder if it would be viable to include some extra checks in the protocol translation functions in |
This comment was marked as duplicate.
This comment was marked as duplicate.
we've been hit by the same problem, but could solve it by upgrading azure CLI to the latest version. As the trace indicates that azurerm is calling out to Azure CLI just before the problem occurs, comparing AZcli versions might be useful. We had it fail on azure-cli 2.27.2, upgrading to 2.38.0 fixed the problem. |
Experiencing the same issue with Azure CLI 2.39.0. No difference between Windows Terminal (PowerShell) and CMD shell as well. No clue what is going on. |
try after logging into |
I was logged in ( |
I got the same problem today, hope this helps someone: I was logged in per |
same issue today. @marcelltoth's comment resolved it for me. |
Hi all, I believe that provider versions v3.14.0 and later should include additional log messages in the debug output explaining what the provider was trying to return when it encountered this error. If anyone in this discussion can reproduce the problem on a newer version of the provider which has that additional logging, it may help to re-share the updated debug logs (equivalent of what's under "Debug Output/Panic Output" in the original issue above) which will hopefully expose the real underlying problem that is currently being masked by a protocol encoding error. To obtain the debug output, see the Terraform documentation on debugging. |
Thank you |
I'm new to terraform so I don't know if this helps. But. I was getting the same error so came to this thread. I'm doing Microsoft tutorial https://learn.microsoft.com/en-us/azure/developer/terraform/create-resource-group?tabs=azure-cli Exactly same files/code. I forced the provider version in Error message: Line 20 is |
Hi @willdave865, Could you try running that I heard that there's some additional logging in recent versions of the provider that might help explain what real error is hiding behind this encoding error. The original writeup for this issue includes part of a trace log captured with an older version of the provider that didn't have the new log lines yet, and so seeing similar logs with the newer version you are running might give some new information about what's going on here. Thanks! |
Hi @apparentlymart Hope this is of some help. |
Thanks @willdave865! Indeed, this trace log seems to contain exactly what I was hoping for:
This shows the error that the provider was trying to return, which as I suspected seems to just be passed on verbatim from the underlying SDK. And inside that error message there's a sequence which my browser interpreted as the Unicode characters We can also see here why some other folks above were able to get past this error message by running I notice that the latest release of the Azure provider at the time I'm writing this message (v3.40.0) is using the underlying library Given that this error seems correct -- the refresh token has expired -- and given that the exact text of this message seems outside the direct control of the Azure provider, my sense is that the answer here could be to upgrade As I mentioned back at the top, I'm not a member of this provider's development team so I'll leave the final call on this up to that team but I hope the above diagnosis is helpful! |
Hi Devs, I just logout from azure cli then logged in again as mentioned below & It worked fine. for me |
I notice that #20114 upgraded the "terraform-plugin-go" library as a side-effect of its other changes, and so according to the release message in that PR the error message should now be correct from v3.41.0 onwards. I would expect it to now report that the token has expired, rather than reporting that the provider's error message is not encoded correctly. However, I've not verified it because I don't work routinely with Azure and so I don't know how to set up the situation where this error message appears. If someone else could try it and report back then that could be helpful to confirm whether this is fixed or whether there's still something more to do. |
Thanks for taking the time to submit this issue. It looks like this has been resolved as of #20114. As such, I am going to mark this issue as closed. |
Is there an existing issue for this?
Community Note
Terraform Version
1.2.4
AzureRM Provider Version
3.13.0
Affected Resource(s)/Data Source(s)
azurerm_resource_group
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
terraform plan should return without error
Actual Behaviour
│ Error: Plugin error
│
│ with provider["registry.terraform.io/hashicorp/azurerm"],
│ on test.tf line 10, in provider "azurerm":
│ 10: provider "azurerm" {
│
│ The plugin returned an unexpected error from plugin.(*GRPCProvider).ConfigureProvider: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8
Steps to Reproduce
terraform plan
Important Factoids
Running on Windows 10, script was a newly written file with current version of Visual Studio Code
References
No response
The text was updated successfully, but these errors were encountered: