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

YAML numbers (unquoted) starting with 0 come to Terraform object string field as 1122 instead of what was typed #410

Open
hypnotisttom opened this issue Jul 17, 2023 · 2 comments
Labels
bug 🐛 An issue with the system enhancement New feature or request

Comments

@hypnotisttom
Copy link

Describe the Bug

Using a terraform object with a string field, if I then set the string field value in the catalog to a number starting with 0 (in this case, it was an address object, and this field is the zip code), atmos seems to think the field value is 1122 instead of 08989, for example. If I quote the 08989, it works. If I do a "describe component" for the unquoted number, atmos indicates the 1122 was specified in the yaml file when it wasn't.

Not as urgent as I have a workaround. Just wanted to report the finding.

Expected Behavior

I would expect the 08989 (in this example) to be the value passed to the terraform component, just like it does if the number was 12345 (not starting with 0).

Steps to Reproduce

  1. Create a terraform variable object that contains at least one string field (I have not tested this with a type=string, only a type=object({ zip_code = string})
  2. Set up the catalog yaml to send an unquoted 5-digit number beginning with 0 as the value for this field
  3. Run "atmos describe component" and see that atmos thinks 1122 is what was configured

I should note that I found this because I added a 5-digit validation rule to the terraform component, and terraform said it only got 4 digits. Digging further is how I found the 1122.

Screenshots

No response

Environment

No response

Additional Context

No response

@hypnotisttom hypnotisttom added the bug 🐛 An issue with the system label Jul 17, 2023
@aknysh
Copy link
Member

aknysh commented Jul 17, 2023

@hypnotisttom thanks again!.

Note that this is not an Atmos issue, this is how YAML behaves.

stoplightio/spectral#1345

Before it even gets to Atmos code and then to Terraform, the YAML parser thinks that the unquoted string is a number and removes the leading zero from it (so Atmos does ot know anything about the type and can't do anything about it).

According to Core schema , 0125487936 would indeed not be a string but a number. Would you ensure it to be parsed as a string, surrounding it with double quotes should do the trick.

In summary, it's better to always quote ALL strings - fewer errors but prob less readable YAML code

@hypnotisttom
Copy link
Author

Thanks @aknysh! I was confused as to why Atmos was showing 1122 as the number when I did something like 08989. Shouldn't "atmos describe component" have shown 8989 then if it is just dropping the 0, or am I misunderstanding? I was surprised "atmos describe component" showed the 4 digits different from the number after dropping the 0.

@osterman osterman added the enhancement New feature or request label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants