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]: Fixed-response in ALB listener rule fails with multibyte characters exceeding 342 characters #37802

Open
akhn1004 opened this issue Jun 2, 2024 · 4 comments
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.

Comments

@akhn1004
Copy link

akhn1004 commented Jun 2, 2024

Terraform Core Version

1.7.5

AWS Provider Version

5.5.2

Affected Resource(s)

  • aws_lb_listener_rule

Expected Behavior

Can be configured with 1024 characters (even multi byte characters).

Actual Behavior

Failure in terraform plan.

Error: expected length of action.0.fixed_response.0.message_body to be in the range (0 - 1024), got ......

Relevant Error/Panic Output Snippet

│ Error: expected length of action.0.fixed_response.0.message_body to be in the range (0 - 1024), got 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
│
│   with aws_lb_listener_rule.test,
│   on share_elb_main.tf line 94, in resource "aws_lb_listener_rule" "test":
│   94:       message_body = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012"

Terraform Configuration Files

resource "aws_lb_listener_rule" "test" {
  listener_arn = aws_alb_listener.test.arn
  priority     = 100
  action {
    type = "fixed-response"

    fixed_response {
      content_type = "text/plain"
      message_body = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012"
      status_code  = 200
    }
  }

Steps to Reproduce

  1. Create an empty AWS ALB.
  2. Create an empty AWS ELB listener.
  3. Create an empty AWS ELB target group.
  4. Create a AWS ELB listerner rule with fixed_response. Set 342 characters in message body of fixed_response.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@akhn1004 akhn1004 added the bug Addresses a defect in current functionality. label Jun 2, 2024
@github-actions github-actions bot added the service/elbv2 Issues and PRs that pertain to the elbv2 service. label Jun 2, 2024
Copy link

github-actions bot commented Jun 2, 2024

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.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 2, 2024
@akhn1004
Copy link
Author

akhn1004 commented Jun 2, 2024

I set default_action / fixed_response to ELB listener and set more than 342 characters as well and it failed with plan as well.

@justinretzolk
Copy link
Member

@akhn1004 👋 Thanks for taking the time to raise this! It looks like the validation is checking byte length rather than character length (removing a couple of characters to get it under 1024 bytes made the validation pass). Are you able to do the same from the API without issue?

$ export TEST_STRING='12345678901234567890123456789012345678901234567890123456789012345678901234567890 1234567890123456789012345678901234567890123456789012345678901234567890123456 789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012'

# byte count
$ echo "$TEST_STRING" | wc -c
    1028

# word count
$ echo "$TEST_STRING" | wc -m
     344

@justinretzolk justinretzolk added the waiting-response Maintainers are waiting on response from community or contributor. label Jun 13, 2024
@pf-siedler
Copy link

I had same issue.

I tried it on managed console.
I created listener rule contain multibyte strings (600 characters / 1800 bytes). It passed.

スクリーンショット 2024-09-18 13 37 09

but, terraform validation failed.

$ terraform plan
╷
│ Error: expected length of action.0.fixed_response.0.message_body to be in the range (0 - 1024), got ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ
│ 
│   with aws_lb_listener_rule.multibyte_string,
│   on main.tf line 47, in resource "aws_lb_listener_rule" "multibyte_string":
│   47:       message_body = "ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ"
│ 
╵

That validation is defined here.

ValidateFunc: validation.StringLenBetween(0, 1024),

StringLenBetween is defined here.
https://github.com/hashicorp/terraform-plugin-sdk/blob/843f27434cd7d30104dbee895e5767a61239ccea/helper/validation/strings.go#L82

len() counts byte size (not character).

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 18, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
Development

No branches or pull requests

3 participants