During the reads and writes of the compressedProtoFile or compressedJsonDescriptor from a grpc test, the provider is calling json.Marshall and json.Unmarshall. Because these calls are transforming string into string, they are escaping / unescaping double quotes (and other characters), to allow this string to be put in a json payload. On the other hand, the web-ui client is not doing this escaping.
For plain proto file, this transformation is probably idempotent most of the time, and wasn't discovered / wasn't causing any issues.
For json descriptors, on the other hand, when json.Unmarshall is taking a string with escaped quotes from a terraformed test, it turns it into a string with unescaped quotes successfully (this string represents a json payload).
But when json.Unmarshall is taking a string with unescaped quotes, trying to unmarshall to turn it into a string, because the input is representing valid JSON, it cannot be unmarshalled into a string, and the string ends up being empty.
json.Unmarshall is returning an error (error: json: cannot unmarshal object into Go value of type string), but this error wasn't caught.
A small reproduction of the issue can be found in this playground.
Because of this, the terraform provider could not read the grpc tests created from web-ui.
During the reads and writes of the
compressedProtoFile
orcompressedJsonDescriptor
from a grpc test, the provider is callingjson.Marshall
andjson.Unmarshall
. Because these calls are transforming string into string, they are escaping / unescaping double quotes (and other characters), to allow this string to be put in a json payload. On the other hand, the web-ui client is not doing this escaping.For plain proto file, this transformation is probably idempotent most of the time, and wasn't discovered / wasn't causing any issues. For json descriptors, on the other hand, when
json.Unmarshall
is taking a string with escaped quotes from a terraformed test, it turns it into a string with unescaped quotes successfully (this string represents a json payload). But whenjson.Unmarshall
is taking a string with unescaped quotes, trying to unmarshall to turn it into a string, because the input is representing valid JSON, it cannot be unmarshalled into a string, and the string ends up being empty.json.Unmarshall
is returning an error (error: json: cannot unmarshal object into Go value of type string
), but this error wasn't caught. A small reproduction of the issue can be found in this playground.Because of this, the terraform provider could not read the grpc tests created from web-ui.