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

[Bug]: Apply fails on create or update operation for aws_quicksight_analysis because Terraform sends empty string for some fields #33035

Closed
udidn opened this issue Aug 16, 2023 · 4 comments
Labels
bug Addresses a defect in current functionality. service/quicksight Issues and PRs that pertain to the quicksight service.
Milestone

Comments

@udidn
Copy link

udidn commented Aug 16, 2023

Terraform Core Version

1.5.3

AWS Provider Version

5.12.0

Affected Resource(s)

parameter_controls block under sheets block under definition block in aws_quicksight_analysis resource

Expected Behavior

Given the following parameter_controls block in the configuration file (under sheets block under definition block in aws_quicksight_analysis):

parameter_controls {
  dropdown {
    parameter_control_id  = "control-id1"
    source_parameter_name = "TestParameter1"
    title                 = "Test Control 1"
    display_options {
      select_all_options {
        visibility = "VISIBLE"
      }
      title_options {
        visibility = "VISIBLE"
        font_configuration {
          font_size {
            relative = "MEDIUM"
          }
        }
      }
    }
    type = "MULTI_SELECT"
    selectable_values {
      link_to_data_set_column {
        column_name         = "column1"
        data_set_identifier = aws_quicksight_data_set.test.name
      }
    }
  }
}

The following fields that are part of the FontConfiguration block must NOT be sent in the HTTP request:

  • FontColor
  • FontDecoration
  • FontStyle

Actual Behavior

Given the following parameter_controls block in the configuration file (under sheets block under definition block in aws_quicksight_analysis):

parameter_controls {
  dropdown {
    parameter_control_id  = "control-id1"
    source_parameter_name = "TestParameter1"
    title                 = "Test Control 1"
    display_options {
      select_all_options {
        visibility = "VISIBLE"
      }
      title_options {
        visibility = "VISIBLE"
        font_configuration {
          font_size {
            relative = "MEDIUM"
          }
        }
      }
    }
    type = "MULTI_SELECT"
    selectable_values {
      link_to_data_set_column {
        column_name         = "column1"
        data_set_identifier = aws_quicksight_data_set.test.name
      }
    }
  }
}

The following fields that are part of the FontConfiguration block are sent in the HTTP request, with an empty string as value:

  • FontColor
  • FontDecoration
  • FontStyle

This causes the QuickSight API to return an HTTP response with HTTP 400 status code, and the terraform apply to fail, because the above fields didn't satisfy the constraints.
Debug outputs and error message can be found in the "Relevant Error/Panic Output Snippet" and "Debug Output" sections

Relevant Error/Panic Output Snippet

HTTP 400 status code error response body:
{
    "message": "6 validation errors detected: Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontDecoration' failed to satisfy constraint: Member must satisfy enum value set: [UNDERLINE, NONE]; Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontStyle' failed to satisfy constraint: Member must satisfy enum value set: [NORMAL, ITALIC]; Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontColor' failed to satisfy constraint: Member must satisfy regular expression pattern: ^#[A-F0-9]{6}$; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontDecoration' failed to satisfy constraint: Member must satisfy enum value set: [UNDERLINE, NONE]; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontStyle' failed to satisfy constraint: Member must satisfy enum value set: [NORMAL, ITALIC]; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontColor' failed to satisfy constraint: Member must satisfy regular expression pattern: ^#[A-F0-9]{6}$"
}

Terraform error:
Error: creating Amazon QuickSight Analysis (eks_insights_tf): ValidationException: 6 validation errors detected: Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontDecoration' failed to satisfy constraint: Member must satisfy enum value set: [UNDERLINE, NONE]; Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontStyle' failed to satisfy constraint: Member must satisfy enum value set: [NORMAL, ITALIC]; Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontColor' failed to satisfy constraint: Member must satisfy regular expression pattern: ^#[A-F0-9]{6}$; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontDecoration' failed to satisfy constraint: Member must satisfy enum value set: [UNDERLINE, NONE]; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontStyle' failed to satisfy constraint: Member must satisfy enum value set: [NORMAL, ITALIC]; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontColor' failed to satisfy constraint: Member must satisfy regular expression pattern: ^#[A-F0-9]{6}$
│ 	status code: 400, request id: <id>

Terraform Configuration Files

resource "aws_quicksight_analysis" "test" {
  analysis_id = "test"
  name        = "test"
  theme_arn   = "arn:aws:quicksight::aws:theme/CLASSIC"

  definition {
    data_set_identifiers_declarations {
      identifier   = aws_quicksight_data_set.test.name
      data_set_arn = aws_quicksight_data_set.test.arn
    }

    sheets {
      sheet_id = "sheet-id1"
      description = "Some description"
      name = "Some Name"
      content_type = "INTERACTIVE"
      text_boxes {
        sheet_text_box_id = "textbox-id"
        content = "Some text here"
      }
      layouts {
        configuration {
          grid_layout {
            elements {
              column_index = 0
              column_span  = 36
              element_id   = "element-id1"
              element_type = "TEXT_BOX"
              row_index    = 0
              row_span     = 3
            }
          }
        }
      }
      parameter_controls {
        dropdown {
          parameter_control_id  = "control-id1"
          source_parameter_name = "TestParameter1"
          title                 = "Test Control 1"
          display_options {
            select_all_options {
              visibility = "VISIBLE"
            }
            title_options {
              visibility = "VISIBLE"
              font_configuration {
                font_size {
                  relative = "MEDIUM"
                }
              }
            }
          }
          type = "MULTI_SELECT"
          selectable_values {
            link_to_data_set_column {
              column_name         = "column1"
              data_set_identifier = aws_quicksight_data_set.test.name
            }
          }
        }
      }
      parameter_controls {
        dropdown {
          parameter_control_id  = "control-id2"
          source_parameter_name = "TestParameter2"
          title                 = "Test Control 2"
          display_options {
            select_all_options {
              visibility = "VISIBLE"
            }
            title_options {
              visibility = "VISIBLE"
              font_configuration {
                font_size {
                  relative = "MEDIUM"
                }
              }
            }
          }
          type = "MULTI_SELECT"
          selectable_values {
            link_to_data_set_column {
              column_name         = "column2"
              data_set_identifier = aws_quicksight_data_set.test.name
            }
          }
          cascading_control_configuration {
            source_controls {
              source_sheet_control_id = "control-id1"
              column_to_match {
                column_name         = "column1"
                data_set_identifier = aws_quicksight_data_set.test.name
              }
            }
          }
        }
      }
    }

    analysis_defaults {
      default_new_sheet_configuration {
        interactive_layout_configuration {
          grid {
            canvas_size_options {
              screen_canvas_size_options {
                resize_option             = "FIXED"
                optimized_view_port_width = "1600px"
              }
            }
          }
        }
        sheet_content_type = "INTERACTIVE"
      }
    }
  }
}

Steps to Reproduce

  1. Set environment variable export TF_LOG=DEBUG
  2. Run 'terraform apply' (creating the aws_quicksight_analysis resource from scratch)

After the apply, you'll see debug logs showing the HTTP request body with the empty fields I mentioned in the "Actual Behavior" section.
See more in the "Debug Output" section

  1. To recreate the issue in an update operation, run terraform apply without the parameter_controls block
  2. After the "apply" operation is successful, add the parameter_controls and run terraform apply
    You'll see the same issue happens on an update operation too

Debug Output

After running terraform apply to create the aws_quicksight_analysis resource from scratch, you'll see the following logs:

2023-08-16T10:39:13.560+0300 [INFO]  Starting apply for module.dashboard.aws_quicksight_analysis.test
2023-08-16T10:39:13.695+0300 [DEBUG] module.dashboard.aws_quicksight_analysis.test: applying the planned Create change
2023-08-16T10:39:13.789+0300 [DEBUG] provider.terraform-provider-aws_v5.12.0_x5: [DEBUG] setting computed for "parameters" from ComputedKeys
2023-08-16T10:39:13.796+0300 [DEBUG] provider.terraform-provider-aws_v5.12.0_x5: HTTP Request Sent: http.user_agent="APN/1.0 HashiCorp/1.0 Terraform/1.5.3 (+https://www.terraform.io) terraform-provider-aws/5.12.0 (+https://registry.terraform.io/providers/hashicorp/aws) aws-sdk-go/1.44.321 (go1.20.6; darwin; arm64)" tf_resource_type=aws_quicksight_analysis aws.sdk=aws-sdk-go http.flavor=1.1 http.method=POST http.request.body=

After the http.request.body= there will be the body of the QuickSight CreateAnalysis API call.
Here's the relevant snippet:

"ParameterControls":
[
    {
        "Dropdown":
        {
            "DisplayOptions":
            {
                "SelectAllOptions":
                {
                    "Visibility": "VISIBLE"
                },
                "TitleOptions":
                {
                    "CustomLabel": "",
                    "FontConfiguration":
                    {
                        "FontColor": "",
                        "FontDecoration": "",
                        "FontSize":
                        {
                            "Relative": "MEDIUM"
                        },
                        "FontStyle": ""
                    },
                    "Visibility": "VISIBLE"
                }
            },
            "ParameterControlId": "control-id1",
            "SelectableValues":
            {
                "LinkToDataSetColumn":
                {
                    "ColumnName": "column1",
                    "DataSetIdentifier": "test"
                }
            },
            "SourceParameterName": "TestParameter1",
            "Title": "Test Control 1",
            "Type": "MULTI_SELECT"
        }
    },
    {
        "Dropdown":
        {
            "CascadingControlConfiguration":
            {
                "SourceControls":
                [
                    {
                        "ColumnToMatch":
                        {
                            "ColumnName": "column1",
                            "DataSetIdentifier": "test"
                        },
                        "SourceSheetControlId": "control-id1"
                    }
                ]
            },
            "DisplayOptions":
            {
                "SelectAllOptions":
                {
                    "Visibility": "VISIBLE"
                },
                "TitleOptions":
                {
                    "CustomLabel": "",
                    "FontConfiguration":
                    {
                        "FontColor": "",
                        "FontDecoration": "",
                        "FontSize":
                        {
                            "Relative": "MEDIUM"
                        },
                        "FontStyle": ""
                    },
                    "Visibility": "VISIBLE"
                }
            },
            "ParameterControlId": "control-id2",
            "SelectableValues":
            {
                "LinkToDataSetColumn":
                {
                    "ColumnName": "column2",
                    "DataSetIdentifier": "test"
                }
            },
            "SourceParameterName": "TestParameter2",
            "Title": "Test Control 2",
            "Type": "MULTI_SELECT"
        }
    }
]

As you can see, the following fields that are part of the FontConfiguration block are sent in the HTTP request, with an empty string as value:

  • FontColor
  • FontDecoration
  • FontStyle

This causes the QuickSight API to return an HTTP response with HTTP 400 status code, with the following message:

{
    "message": "6 validation errors detected: Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontDecoration' failed to satisfy constraint: Member must satisfy enum value set: [UNDERLINE, NONE]; Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontStyle' failed to satisfy constraint: Member must satisfy enum value set: [NORMAL, ITALIC]; Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontColor' failed to satisfy constraint: Member must satisfy regular expression pattern: ^#[A-F0-9]{6}$; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontDecoration' failed to satisfy constraint: Member must satisfy enum value set: [UNDERLINE, NONE]; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontStyle' failed to satisfy constraint: Member must satisfy enum value set: [NORMAL, ITALIC]; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontColor' failed to satisfy constraint: Member must satisfy regular expression pattern: ^#[A-F0-9]{6}$"
}

This causes the terraform apply to fail with the following error message:

Error: creating Amazon QuickSight Analysis (test): ValidationException: 6 validation errors detected: Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontDecoration' failed to satisfy constraint: Member must satisfy enum value set: [UNDERLINE, NONE]; Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontStyle' failed to satisfy constraint: Member must satisfy enum value set: [NORMAL, ITALIC]; Value '' at 'definition.sheets.1.member.parameterControls.1.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontColor' failed to satisfy constraint: Member must satisfy regular expression pattern: ^#[A-F0-9]{6}$; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontDecoration' failed to satisfy constraint: Member must satisfy enum value set: [UNDERLINE, NONE]; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontStyle' failed to satisfy constraint: Member must satisfy enum value set: [NORMAL, ITALIC]; Value '' at 'definition.sheets.1.member.parameterControls.2.member.dropdown.displayOptions.titleOptions.fontConfiguration.fontColor' failed to satisfy constraint: Member must satisfy regular expression pattern: ^#[A-F0-9]{6}$
│ 	status code: 400, request id: <id>

Similar errors are showing on an update operation, as explained in the "Steps to Reproduce" section

Panic Output

No response

Important Factoids

The parameter_controls block that is used in this recreation, contains the dropdown block, but there are also other parameter control types in QuickSight (see here).
I didn't try the rest, I only tried with dropdown, but the issue may be recreated with the other parameter controls types too

References

Would you like to implement a fix?

None

@udidn udidn added the bug Addresses a defect in current functionality. label Aug 16, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/quicksight Issues and PRs that pertain to the quicksight service. label Aug 16, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Aug 16, 2023
@jar-b jar-b removed the needs-triage Waiting for first response or review from a maintainer. label Aug 16, 2023
@jar-b
Copy link
Member

jar-b commented Aug 16, 2023

Fixed by #33018

The font_configuration block nested inside definition.sheets.parameter_controls.dropdown.display_options.title_options shares the same underlying schema and flex functions modified in that PR.

Specifically, this change prevents empty strings from being sent for the arguments noted in the original issue body.

-	if v, ok := tfMap["font_color"].(string); ok {
+	if v, ok := tfMap["font_color"].(string); ok && v != "" {
		config.FontColor = aws.String(v)
	}
-	if v, ok := tfMap["font_decoration"].(string); ok {
+	if v, ok := tfMap["font_decoration"].(string); ok && v != "" {
		config.FontDecoration = aws.String(v)
	}
-	if v, ok := tfMap["font_style"].(string); ok {
+	if v, ok := tfMap["font_style"].(string); ok && v != "" {
		config.FontStyle = aws.String(v)
	}

@jar-b jar-b closed this as completed Aug 16, 2023
@jar-b jar-b added this to the v5.13.0 milestone Aug 16, 2023
@github-actions
Copy link

This functionality has been released in v5.13.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/quicksight Issues and PRs that pertain to the quicksight service.
Projects
None yet
Development

No branches or pull requests

2 participants