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 encoding converting strings to decimals #229

Open
rickeyski opened this issue Aug 29, 2024 · 0 comments
Open

Yaml encoding converting strings to decimals #229

rickeyski opened this issue Aug 29, 2024 · 0 comments

Comments

@rickeyski
Copy link

Hi,

I have a project on LTS-21.25 (ghc 9.4.8, yaml 0.11.11.2) that is manipulating K8s manifests. We encountered an issue where attempting to decode and then re-encode the same yaml files creates errors because a string of ".1" is converted to a decimal of .1.

A minimal repoducer is

env:
- name: ACTIVE_API_CALLS_ALLOWED
  value: "10"
- name: ENABLE_SQLITE_STORED_PROCS
  value: "true"
- name: SQLITE_CHECK_SAME_THREAD_FALSE
  value: "true"
- name: WORKFLOW_SCHEDULER_SLEEP_SECS
  value: ".1"

When tested via ghci

import qualified Data.Yaml as Y
import Data.Aeson

> y :: Value <- Y.decodeFileThrow "file.yaml"
> show y -- Shows the value of WORKFLOW_SCHEDULER_SLEEP_SECS as string
"Object (fromList [("env",Array [Object (fromList [("name",String "ACTIVE_API_CALLS_ALLOWED"),("value",String "10")]),Object (fromList [("name",String "ENABLE_SQLITE_STORED_PROCS"),("value",String "true")]),Object (fromList [("name",String "SQLITE_CHECK_SAME_THREAD_FALSE"),("value",String "true")]),Object (fromList [("name",String "WORKFLOW_SCHEDULER_SLEEP_SECS"),("value",String ".1")])])])"
> Y.encode y -- yaml encoding
"env:
- name: ACTIVE_API_CALLS_ALLOWED
  value: '10'
- name: ENABLE_SQLITE_STORED_PROCS
  value: 'true'
- name: SQLITE_CHECK_SAME_THREAD_FALSE
  value: 'true'
- name: WORKFLOW_SCHEDULER_SLEEP_SECS
  value: .1 # no longer a string
"
> encode y -- Aeson encoding
"{"env":[{"name":"ACTIVE_API_CALLS_ALLOWED","value":"10"},{"name":"ENABLE_SQLITE_STORED_PROCS","value":"true"},{"name":"SQLITE_CHECK_SAME_THREAD_FALSE","value":"true"},{"name":"WORKFLOW_SCHEDULER_SLEEP_SECS","value":".1"}]}"

For reference, Aeson behaves correctly keeping the value that was a string as a string. Please let me know if any other information is required.

Thanks,
Rickey

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

No branches or pull requests

1 participant