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

yamlfix breaks volumes: ["/a:/b"] by removing the quoting, making the list item a mapping #283

Open
lalten opened this issue Jul 30, 2024 · 2 comments · May be fixed by #284
Open

yamlfix breaks volumes: ["/a:/b"] by removing the quoting, making the list item a mapping #283

lalten opened this issue Jul 30, 2024 · 2 comments · May be fixed by #284
Labels
bug Something isn't working

Comments

@lalten
Copy link

lalten commented Jul 30, 2024

Description

yamlfix breaks volumes: ["/a:/b"] by removing the quoting, making the list item a mapping.

See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes

It looks like this is a ruyaml bug as this happens in

self.yaml.dump(source_dict, string_stream)

Steps to reproduce

❯ yamlfix - <<<'volumes: ["/a:/b"]'
[+] YamlFix: Fixing files
[+] Fixed <stdin>
---
volumes: [/a:/b]

Current behavior

yamlfix breaks volumes: ["/a:/b"] by removing the quoting, making the list item a mapping.

Desired behavior

Don't break the yaml on formatting

Environment

yamlfix: 1.16.0
Python: 3.10.12
Platform: Linux-6.5.0-1018-oem-x86_64-with-glibc2.35
@lalten lalten added the bug Something isn't working label Jul 30, 2024
@lalten
Copy link
Author

lalten commented Jul 30, 2024

It seems this is a bug in check-yaml which complains

while scanning a plain scalar
  in ".github/workflows/workflow.yml", line 19, column 17
found unexpected ':'
  in ".github/workflows/workflow.yml", line 19, column 43

Some testing with yq shows that this seems to be ok yaml:

❯ yq <<<'volumes: [a:b]'
{
  "volumes": [
    "a:b"
  ]
}
❯ yq <<<'volumes: ["a:b"]'
{
  "volumes": [
    "a:b"
  ]
}
❯ yq <<<'volumes: ["a: b"]'
{
  "volumes": [
    "a: b"
  ]
}
❯ yq <<<'volumes: [a: b]'
{
  "volumes": [
    {
      "a": "b"
    }
  ]
}

actionlint also has no issue with volumes: [a:b]

@lalten lalten closed this as completed Jul 30, 2024
@lalten
Copy link
Author

lalten commented Jul 30, 2024

I take it back, GitHub Actions complains

The workflow is not valid. .github/workflows/build.yaml: (Line: 193, Col: 17, Idx: 6509) - (Line: 193, Col: 42, Idx: 6534): While scanning a plain scalar, find unexpected ':'.

@lalten lalten reopened this Aug 5, 2024
@lalten lalten linked a pull request Aug 5, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant