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

Properly format numbers parsed from jsonPath outputs #1755

Merged
merged 1 commit into from
Sep 15, 2021

Conversation

carolynvs
Copy link
Member

What does this change

When we parse outputs for jsonPath expressions, numbers are not being formatted as expected. For example, a number like "123123123" is being output as "1.23123123e+08".

This is due to how we are parsing the jsonPath. The output is marshaled into a generic map, where json numbers are represented as float64. We use fmt.Sprintf to format the matching output value, and Go by default formats float with %f/%g, neither of which is the desired format.

I've updated our json parsing to use the Number type so that the format of the captured value matches what was used in the original output.

What issue does it fix

Fixes #1754

Notes for the reviewer

They who provide test data to reproduce, get fast bug fixes. ❤️

Checklist

  • Unit Tests
  • Documentation
  • Schema (porter.yaml)

When we parse outputs for jsonPath expressions, numbers are not being
formatted as expected. For example, a number like "123123123" is being
output as "1.23123123e+08".

This is due to how we are parsing the jsonPath. The output is marshaled
into a generic map, where json numbers are represented as float64. We
use fmt.Sprintf to format the matching output value, and Go by default
formats float with %f/%g, neither of which is the desired format.

I've updated our json parsing to use the Number type so that the format
of the captured value matches what was used in the original output.

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs
Copy link
Member Author

I'm going to hold off on anymore merges until our free oss status is fixed in Azure DevOps. That's why all the builds immediately fail. 💰

@carolynvs carolynvs merged commit aae52d4 into getporter:main Sep 15, 2021
@carolynvs carolynvs deleted the format-float-outputs branch September 15, 2021 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Outputs captured with jsonPath format numbers in exponential notation
2 participants