-
Notifications
You must be signed in to change notification settings - Fork 68
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
Incorrect labels in generated markdown for certain deeply-nested schemas #380
Comments
It looks like this was supposed to be fixed in v0.19.0. If I run with v0.18.0, I see one additional incorrect label. At v0.19.0 or later, I only see the one incorrect label I described in the issue. |
Reference: #380 After introducing the new unit test matching the given schema and expected output, prior to the logic change: ``` --- FAIL: TestRender (0.00s) --- FAIL: TestRender/deep_nested_attributes (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-docs/internal/schemamd/render_test.go:91: Unexpected diff (-wanted, +got): strings.Join({ ... // 1062 identical bytes "el_two.level_three.level_four_primary. (see [below for nested sc", "hema](#nestedatt--level_one--level_two--level_three--level_four_", - "prim", + "second", "ary--level_five))\n- `level_four_primary_string` (String) Parent ", "should be level_one.level_two.level_three.level_four_primary.\n\n<", `a id="nestedatt--level_one--level_two--level_three--level_four_`, - "prim", + "second", "ary--level_five\"></a>\n### Nested Schema for `level_one.level_two", ".level_three.level_four_", - "prim", + "second", "ary.level_five`\n\nOptional:\n\n- `level_five_string` (String) Paren", "t should be level_one.level_two.level_three.level_four_primary.l", "evel_five.", }, "") ```
Hi @henryrecker-pingidentity 👋 Thank you for submitting this bug report and sorry for the frustrating behavior. Very much appreciate the full reproduction setup as that made tracking this down so much easier. It looks like there was some errant reuse of attribute paths in the generator code, which should be resolved with #382. 👍 |
…ing (#382) Reference: #380 After introducing the new unit test matching the given schema and expected output, prior to the logic change: ``` --- FAIL: TestRender (0.00s) --- FAIL: TestRender/deep_nested_attributes (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-docs/internal/schemamd/render_test.go:91: Unexpected diff (-wanted, +got): strings.Join({ ... // 1062 identical bytes "el_two.level_three.level_four_primary. (see [below for nested sc", "hema](#nestedatt--level_one--level_two--level_three--level_four_", - "prim", + "second", "ary--level_five))\n- `level_four_primary_string` (String) Parent ", "should be level_one.level_two.level_three.level_four_primary.\n\n<", `a id="nestedatt--level_one--level_two--level_three--level_four_`, - "prim", + "second", "ary--level_five\"></a>\n### Nested Schema for `level_one.level_two", ".level_three.level_four_", - "prim", + "second", "ary.level_five`\n\nOptional:\n\n- `level_five_string` (String) Paren", "t should be level_one.level_two.level_three.level_four_primary.l", "evel_five.", }, "") ```
This will likely be released tomorrow in a terraform-plugin-docs v0.19.4 release. 👍 |
Terraform CLI and terraform-plugin-docs Versions
Provider Code
Expected Behavior
Labels in generated documentation should be correct, including names of parent attributes up the chain
Actual Behavior
Links in the generated
example.md
file go to the right place, but the labels of the sections can be wrong. With this schema, one label treats an adjacent StringAttribute as if it was the parent SingleNestedAttribute.Note the "Nested Schema for
level_one.level_two.level_three.level_four_secondary.level_five
": thatlevel_four_secondary
attribute is just a string, it can't have child attributes, yet the generated doc includes it as a parent in the label for the nested schema.I'm not sure whether or not this is the simplest schema to reproduce this issue. I tried several variations. It seems that this can happen under ListNested attributes as well at minimum. I tried reducing the nesting from the amount in my example here but then the bug stopped occurring, so it may somehow be related to very deep nesting.
Steps to Reproduce
tfplugindocs generate
with a provider with a resource with the given schemaThe code I copied here as well as the generated markdown can also be viewed in the DocsBug branch linked here - https://github.com/henryrecker-pingidentity/terraform-provider-example/tree/DocsBug
How much impact is this issue causing?
Medium
Logs
No response
Additional Information
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: