terraform-plugin-framework icon indicating copy to clipboard operation
terraform-plugin-framework copied to clipboard

Crashes when converting Schema

Open AndreasBergmeier6176 opened this issue 3 years ago • 2 comments

Module version

github.com/hashicorp/terraform-plugin-framework v0.13.0

Relevant provider source code

Seems to be triggered by:

"cache": {
  Attributes: tfsdk.SingleNestedAttributes(
    map[string]tfsdk.Attribute{
    }
  ),
}                                    

Terraform Configuration Files

Debug Output

Expected Behavior

Should produce an error but not crash.

Actual Behavior

Crashes with:

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

runtime error: invalid memory address or nil pointer dereference

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
goroutine 39 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        /home/circleci/project/project/internal/logging/panic.go:55 +0x154
panic({0x223c280, 0x3fdab50})
        /usr/local/go/src/runtime/panic.go:1038 +0x215
github.com/hashicorp/terraform/internal/plugin6/convert.ProtoToConfigSchema(0x0)
        /home/circleci/project/project/internal/plugin6/convert/schema.go:110 +0x52
github.com/hashicorp/terraform/internal/plugin6/convert.ProtoToProviderSchema(...)
        /home/circleci/project/project/internal/plugin6/convert/schema.go:98
github.com/hashicorp/terraform/internal/plugin6.(*GRPCProvider).GetProviderSchema(0xc000ea2000)
        /home/circleci/project/project/internal/plugin6/grpc_provider.go:164 +0x62c
github.com/hashicorp/terraform/internal/terraform.(*contextPlugins).ProviderSchema(0xc000b8bf80, {{0xc000532bdb, 0x8}, {0xc000532bd0, 0xa}, {0x25ea9f1, 0x15}})
        /home/circleci/project/project/internal/terraform/context_plugins.go:97 +0x3aa
github.com/hashicorp/terraform/internal/terraform.loadProviderSchemas.func1({{0xc000532bdb, 0x8}, {0xc000532bd0, 0xa}, {0x25ea9f1, 0x15}})
        /home/circleci/project/project/internal/terraform/schemas.go:103 +0x33a
github.com/hashicorp/terraform/internal/terraform.loadProviderSchemas(0x7f4e58c64fff, 0x40, 0x0, 0xc00093f2b0)
        /home/circleci/project/project/internal/terraform/schemas.go:124 +0x1eb
github.com/hashicorp/terraform/internal/terraform.loadSchemas(0xc00093f320, 0x40d067, 0xc00093f320)
        /home/circleci/project/project/internal/terraform/schemas.go:84 +0xaa
github.com/hashicorp/terraform/internal/terraform.(*Context).Schemas(0xc000bab100, 0xc000bab080, 0xc00093f367)
        /home/circleci/project/project/internal/terraform/context.go:157 +0x2a
github.com/hashicorp/terraform/internal/terraform.(*Context).Input(0xc000bab100, 0xc00032bea0, 0x1)
        /home/circleci/project/project/internal/terraform/context_input.go:48 +0x9e
github.com/hashicorp/terraform/internal/backend/local.(*Local).localRun(0xc000879860, 0xc0009d9680)
        /home/circleci/project/project/internal/backend/local/backend_local.go:113 +0x9ec
github.com/hashicorp/terraform/internal/backend/local.(*Local).opApply(0x0, {0x2b28338, 0xc0009dbb00}, {0x2b28338, 0xc0009dbb40}, 0xc0009d9680, 0xc0009dbac0)
        /home/circleci/project/project/internal/backend/local/backend_apply.go:46 +0x285
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
        /home/circleci/project/project/internal/backend/local/backend.go:323 +0xc3
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation
        /home/circleci/project/project/internal/backend/local/backend.go:316 +0x445

Steps to Reproduce

References

AndreasBergmeier6176 avatar Sep 20 '22 08:09 AndreasBergmeier6176

Seems to be Terraform 1.1 specific - with 1.2.9 this is no longer a problem...

AndreasBergmeier6176 avatar Sep 20 '22 09:09 AndreasBergmeier6176

Hi @AndreasBergmeier6176 👋 Thank you for raising this and sorry you ran into trouble here.

That stacktrace is wholly coming from Terraform CLI, e.g.

github.com/hashicorp/terraform/internal/plugin6/convert.ProtoToConfigSchema(0x0)
        /home/circleci/project/project/internal/plugin6/convert/schema.go:110 +0x52

So any fixes to raise a proper error instead of a panic would need to be handled there, but the good news is that this should've been covered already when we noticed this with #326, where Terraform CLI wasn't properly checking for errors first when receiving the provider schema RPC response. Those fixes in Terraform CLI were part of https://github.com/hashicorp/terraform/pull/31184 / https://github.com/hashicorp/terraform/pull/31190 and should've been released with Terraform 1.2.3 according to the changelog.

bflad avatar Sep 20 '22 14:09 bflad

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Jan 13 '23 02:01 github-actions[bot]