-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
Long number string variables are now converted to scientific notation, breaking existing tasks that expect the number as is #1658
Comments
This is behaving as intended. Since Task now supports any scalar variable type, if you give it a number, it will be interpreted as one (rather than the previous behaviour which automatically converted it to a string). Since the number you used far exceeds the maximum signed and unsigned 64 bit integer size, it is converted to a float approximation instead and when printed it will be displayed using scientific notation. If you want your variable to be a string then you should always wrap it with quotes and it will be interpreted as expected: long-number:
desc: Print a long number variable
vars:
LONG_NUMBER: "123456789012345678901234567890"
cmds:
- echo "{{.LONG_NUMBER}}" |
I figured this might be the intended behavior and included the bit about the quotes after the example I provided. For future reference, should I assume minor version bumps could introduce breaking changes? |
We don't (intentionally) make breaking changes in minor/patch versions. We follow SemVer rules for our CLI binary (Though it's worth remembering that the Golang package API does not share this compatibility guarantee). This is one of the reasons why we have experiment flags (for testing breaking changes to be made in future major releases). I understand that this release made some Taskfiles behave differently. However, I would argue that this is still not considered to be a breaking change since it only changes the behaviour of incorrectly formatted YAML files. If anything, I would consider the previous behaviour to be buggy and we should have been erroring if we detected non-string variables. The fact that in prior versions, you could define a YAML boolean and then not use Sidenote: One of my least favourite things about YAML is that it lets you define strings without using quotes. It leads to a lot of problems/misunderstandings. Especially given that One thing is for sure though. If you want a string containing numeric-only characters - you need to quote it. |
I understand what you mean about the previous behavior being considered a bug. I guess whether this is considered a "breaking change" is open to interpretation, but I can definitely see your point. Thanks for the explanation! 👍🏻 |
Existing commands that utilize a long number variable as a string are now broken by conversion to scientific notation.
Given this task:
Using task version 3.36.0:
Using task version 3.37.2:
The issue can fixed by just quoting the variable that is meant to be interpreted as a string, but this does break previously existing tasks that utilize unquoted long numbers.
The text was updated successfully, but these errors were encountered: