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

helper/schema: Fix setting a set in a list caused error #19552

Merged
merged 1 commit into from
Dec 10, 2018
Merged

helper/schema: Fix setting a set in a list caused error #19552

merged 1 commit into from
Dec 10, 2018

Conversation

faridnsh
Copy link
Contributor

@faridnsh faridnsh commented Dec 5, 2018

The added test in this commit, without the fix, will make d.Set return
the following error:

Invalid address to set: []string{"ports", "0", "set"}

This was due to the fact that setSet in feild_writer_map tried to
convert a slice into a set by creating a temp set schema and calling
writeField on that with the address([]string{"ports", "0", "set"}" in
this case). However the temp schema was only for the set and not the
whole schema as seen in the address so, it should have been []string{"set"}"
so it would align with the schema.

This commits adds another variable there(tempAddr) which will only
contain the last entry of the address that would be the set key, which
would match the created schema

This commit potentially fixes the problem described in #16331

@faridnsh faridnsh changed the title Fix setting a set in a list caused error helper/schema: Fix setting a set in a list caused error Dec 5, 2018
The added test in this commit, without the fix, will make d.Set return
the following error:

`Invalid address to set: []string{"ports", "0", "set"}`

This was due to the fact that setSet in feild_writer_map tried to
convert a slice into a set by creating a temp set schema and calling
writeField on that with the address(`[]string{"ports", "0", "set"}"` in
this case). However the temp schema was only for the set and not the
whole schema as seen in the address so, it should have been `[]string{"set"}"`
so it would align with the schema.

This commits adds another variable there(tempAddr) which will only
contain the last entry of the address that would be the set key, which
would match the created schema

This commit potentially fixes the problem described in #16331
Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

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

This looks good, thanks for catching this @alFReD-NSH!

@jbardin jbardin merged commit 3d6ec09 into hashicorp:master Dec 10, 2018
@faridnsh faridnsh deleted the bugfix/setting-sets-in-list branch March 18, 2019 08:00
@ghost
Copy link

ghost commented Aug 13, 2019

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.

@ghost ghost locked and limited conversation to collaborators Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants