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

invalid character '\x1b' in string literal #165

Closed
zarko-a opened this issue Mar 19, 2023 · 3 comments
Closed

invalid character '\x1b' in string literal #165

zarko-a opened this issue Mar 19, 2023 · 3 comments
Assignees
Labels
bug Something isn't working released

Comments

@zarko-a
Copy link

zarko-a commented Mar 19, 2023

Describe the bug
Doing a plan against previously created routeros_ip_dhcp_server_lease resource fails when [bound] host name has unusual characters.

It looks like the provider is trying to read and keep track of host_name associated with the lease, then when \x1b [escape character?) is encountered provider exists with an error, and the plan fails with the following error:

Error: invalid character '\x1b' in string literal

  with routeros_ip_dhcp_server_lease.dhcp_reservation["oven"],
  on dhcp.tf line 2, in resource "routeros_ip_dhcp_server_lease" "dhcp_reservation":
   2: resource "routeros_ip_dhcp_server_lease" "dhcp_reservation" {

To Reproduce
Might be difficult to reproduce without the hardware that's acquiring the IP and reporting a messy hostname. In this case it's a GE smart oven.

Host name reported by Mikrotik Winbox looks like this TÇ�0�÷��� .

TF code, not sure if relevant to this scenario"

resource "routeros_ip_dhcp_server_lease" "dhcp_reservation" {
  for_each = { for idx, reservation in local.dhcp_mapping : reservation.name => reservation }

  address     = each.value.ip
  mac_address = each.value.mac
  comment     = "${lookup(each.value, "brand", "")}_${each.value.name}"
  server      = lookup(each.value, "server", null)
}


locals {
 dhcp_mapping = flatten([for k, v in local.dhcp_reservations : [for a, b in v : merge(b, { server = k, name = a })]])

# .....
  dhcp_reservations = {
    # NETWORK BOUNDRY
    defconf = { 
       oven = { 
         mac   = "D8:28:C9:35:09:57",
         ip    = "192.168.88.130",
         brand = "general_electric"
       },
     }
# .....
  }
}

Expected behavior
Working plan. Host name information in this case is not critical and even if it can't be handled properly a more graceful failure would be desirable (like setting the attribute to null).

Stack Trace
Can provide if necessary.

Additional context
N/A

@zarko-a zarko-a added the bug Something isn't working label Mar 19, 2023
@vaerh
Copy link
Collaborator

vaerh commented Mar 20, 2023

OK, I have an idea how to reproduce this problem. But I am not sure that it will be possible to solve it beautifully. Please make a plan with debugging. I'm interested in the lines highlighted in green.

TF_LOG=debug ROS_LOG_COLOR=1 terraform plan

@vaerh vaerh self-assigned this Mar 20, 2023
@vaerh vaerh closed this as completed in 646ba4f Mar 21, 2023
@gfenn-newbury
Copy link
Collaborator

🎉 This issue has been resolved in version 1.1.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

@zarko-a
Copy link
Author

zarko-a commented Mar 25, 2023

Thank you @vaerh . I just tried the new version and it worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

3 participants