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 title and reference links of nested blocks/attributes #56

Merged
merged 1 commit into from Jun 28, 2022

Conversation

zippolyte
Copy link
Contributor

@zippolyte zippolyte commented Apr 22, 2021

The path slice needs to be made a copy of the parents, otherwise when there is enough nesting, the append operation does not do a copy of the slice, and we keep modifying the same reference in the nested blocks, thus generating incorrect titles and links.

As an example, you can check https://registry.terraform.io/providers/DataDog/datadog/2.25.0/docs/resources/dashboard#nestedblock--widget--change_definition--request--apm_query, which is the level of nesting things start to go bad. The title shows the wrong path, but the anchor ID is still ok at this point.

Related issue: DataDog/terraform-provider-datadog#1024

@hashicorp-cla
Copy link

hashicorp-cla commented Apr 22, 2021

CLA assistant check
All committers have signed the CLA.

@mavogel
Copy link

mavogel commented May 17, 2021

@paultyng can we get this merged? The markdown link checker action also triggers on this.

@displague
Copy link

Wondering if this is also related to #28

@detro
Copy link
Contributor

detro commented Jun 28, 2022

Hello @zippolyte - thank you so much for this and the patience.

I frankly had to do a bit of studying and testing to figure out what it is you were fixing: I wasn't part of the original creators of this, so I was like :head-scratch:-ing hard.

Then I found this https://stackoverflow.com/questions/35276022/unexpected-slice-append-behaviour and https://go.dev/play/p/INADVS3Ats. I have also been able to assemble an even weirder example, that shows that this issue with append() might be a genuine bug with the internal Go implementation: https://go.dev/play/p/M4-d16YwdN0

It's likely something with how Go is manipulating the memory created as part of the initial calls to append() and also what it does when it has to access and print it.

Will be merging this.

Copy link
Contributor

@detro detro left a comment

Choose a reason for hiding this comment

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

See #56 (comment)

Thank you so much

@detro detro merged commit cabc562 into hashicorp:main Jun 28, 2022
@detro detro added this to the v0.10.2 milestone Jun 28, 2022
@detro detro added bug Something isn't working go Pull requests that update Go code command/generate labels Jun 28, 2022
@zippolyte zippolyte deleted the hippo/nestedblockspath branch June 29, 2022 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working command/generate go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants