Skip to content
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

Fix gob encoder error on unknown value #1041

Merged
merged 5 commits into from
Jan 24, 2021

Conversation

syndicut
Copy link
Contributor

When using Config() method with --module option you can get cty.unknownType inside module variables without default values and following error:

13:39:46 server.go:418: rpc: gob error encoding body: error encoding cty.Value: gob: type not registered for interface: cty.unknownType

This fix forces cty.Value{} in case of unknown value

@wata727
Copy link
Member

wata727 commented Jan 21, 2021

Umm, I understand this bug, but this fix makes it impossible for plugins to handle variables as unknown.

Maybe gob is not a good way to transfer cty.Value. go-cty seems to support encoding/decoding with msgpack, so I think this might be a good idea, but I haven't started investigating anything yet. If you are interested, I would like to support you as much as possible.
https://pkg.go.dev/github.com/zclconf/[email protected]/cty/msgpack

@syndicut
Copy link
Contributor Author

Umm, I understand this bug, but this fix makes it impossible for plugins to handle variables as unknown.

Maybe gob is not a good way to transfer cty.Value. go-cty seems to support encoding/decoding with msgpack, so I think this might be a good idea, but I haven't started investigating anything yet. If you are interested, I would like to support you as much as possible.
https://pkg.go.dev/github.com/zclconf/[email protected]/cty/msgpack

Ok, good point, will look at it

@syndicut
Copy link
Contributor Author

Umm, I understand this bug, but this fix makes it impossible for plugins to handle variables as unknown.

Maybe gob is not a good way to transfer cty.Value. go-cty seems to support encoding/decoding with msgpack, so I think this might be a good idea, but I haven't started investigating anything yet. If you are interested, I would like to support you as much as possible.
https://pkg.go.dev/github.com/zclconf/[email protected]/cty/msgpack

Think those changes and terraform-linters/tflint-plugin-sdk#96 should do the trick

@wata727
Copy link
Member

wata727 commented Jan 22, 2021

Merged terraform-linters/tflint-plugin-sdk#96. Could you update the sdk version in this PR?

@syndicut
Copy link
Contributor Author

Merged terraform-linters/tflint-plugin-sdk#96. Could you update the sdk version in this PR?

Done!

@syndicut syndicut changed the title Fix gob encoder error on unknown value [WIP] Fix gob encoder error on unknown value Jan 22, 2021
@syndicut syndicut changed the title [WIP] Fix gob encoder error on unknown value Fix gob encoder error on unknown value Jan 22, 2021
plugin/encode.go Outdated Show resolved Hide resolved
Copy link
Member

@wata727 wata727 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@wata727 wata727 merged commit 0ba9b50 into terraform-linters:master Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants