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

Disabling explicit_start breaks multidocument files #274

Open
roobre opened this issue Jan 30, 2024 · 1 comment
Open

Disabling explicit_start breaks multidocument files #274

roobre opened this issue Jan 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@roobre
Copy link

roobre commented Jan 30, 2024

Description

When explicit_start is set to false, yamlfix strips all document separators from a file, potentially breaking it.

Steps to reproduce

Consider the following file with two documents (test.yaml):

document: one
---
document: two

Running yamlfix with explicit_start set to false will break this file:

16:10:20 /tmp/roobre $> cat test.yaml | YAMLFIX_EXPLICIT_START=false ~/.local/share/nvim/mason/bin/yamlfix -
[+] YamlFix: Fixing files
[+] Fixed <stdin>
document: one
document: two

This does not happen if explicit_start is true (default):

16:10:56 /tmp/roobre $> cat test.yaml | ~/.local/share/nvim/mason/bin/yamlfix -
[+] YamlFix: Fixing files
[+] Fixed <stdin>
---
document: one
---
document: two

I think that if explicit_start is set to false, yamlfix should keep existing separators to avoid breaking valid files.

If possible, I think it would be even better if there was a way (explicit_start or otherwise) to tell yamlfix to not mess with the explicit start altogether: Keep it if exists, do not add it if it doesn't, do nothing with other (non-start) separators.

Environment

16:13:21 /tmp/roobre $> ~/.local/share/nvim/mason/bin/yamlfix --version
------------------------------------------------------------------
     yamlfix: 1.16.0
     Python: 3.11.6
     Platform: Linux-6.7.1-arch1-1-x86_64-with-glibc2.38
------------------------------------------------------------------
@roobre roobre added the bug Something isn't working label Jan 30, 2024
@fredleger
Copy link

facing the same issue

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

No branches or pull requests

2 participants