terraform icon indicating copy to clipboard operation
terraform copied to clipboard

panic with nil schema block from grpc `GetSchema`

Open yherve opened this issue 4 years ago • 2 comments

Terraform Version

Terraform v1.0.2
on linux_amd64
+ provider registry.terraform.io/fp/smc v1.0.0

Terraform Configuration Files

...

Debug Output

tflog.traces.txt

Crash Output

crash.610505221.log

Expected Behavior

not crash

Actual Behavior

crash

Steps to Reproduce

Unfortunately I cannot provide you a way to reproduce. I am currently developing a provider, but I am not using the official sdk (I interact directly with the grpc protocol) terraform crashes during the getSchema operation. I have pasted you my own log file where the schema has been dumped.

Additional Context

pytera.log

References

yherve avatar Jul 21 '21 14:07 yherve

Hi @yherve,

It appears that your provider is returning a nil value for a resource block schema, which Terraform is not expecting to handle. The fix in Terraform should be straightforward, checking for a nil value and returning an appropriate error.

I also noticed part of a traceback in the provider logs too, which may indicate that the provider itself encountered an error which is could be contributing to this.

Thanks!

jbardin avatar Jul 21 '21 16:07 jbardin

In addition to what @jbardin said, I'd also note that this is a tricky situation where although we could potentially make a null value just be silently ignored, if we were to do that now then it'd be possible to write a provider that would succeed on newer Terraform versions (where provider developers are most likely to test) but fail on older versions, and thus create difficult-to-diagnose failures.

For that reason, I'd echo @jbardin's point that it'd be better to fix this by explicitly returning an error saying that the provider's response was invalid, so that although it would no longer panic it would still indicate a problem to be solved in the provider-side code in order for the plugin to work successfully for all Terraform versions which support the relevant plugin protocol.

apparentlymart avatar Jul 21 '21 21:07 apparentlymart