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 multiline strings, idempotency problems #280

Open
scoopex opened this issue Jul 7, 2024 · 0 comments
Open

Yamlfix breaks multiline strings, idempotency problems #280

scoopex opened this issue Jul 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@scoopex
Copy link

scoopex commented Jul 7, 2024

The current release (1.16.0/47039c9) breaks multiline strings.

See:

$ git clone [email protected]:SovereignCloudStack/hardware-landscape.git
$ git checkout improve_yaml
$ make lint-fix
.. .
$ make lint-fix
...
./environments/custom/roles/scs-serial-terminals/tasks/main.yml
[+] YamlFix: Fixing files
Traceback (most recent call last):
  File "/home//src/github/redacted/scs/hardware-landscape/venv/bin/yamlfix", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/yamlfix/entrypoints/cli.py", line 119, in cli
    fixed_code, changed = services.fix_files(files_to_fix, check, config)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/yamlfix/services.py", line 83, in fix_files
    fixed_source = fix_code(source, config)
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/yamlfix/services.py", line 162, in fix_code
    source_code = fixer.fix(source_code=source_code)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/yamlfix/adapters.py", line 363, in fix
    source_code = fixer(source_code)
                  ^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/yamlfix/adapters.py", line 381, in _ruamel_yaml_fixer
    for source_dict in source_dicts:
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/main.py", line 477, in load_all
    yield constructor.get_data()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/constructor.py", line 134, in get_data
    return self.construct_document(self.composer.get_node())
                                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/composer.py", line 63, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/composer.py", line 96, in compose_document
    node = self.compose_node(None, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/composer.py", line 140, in compose_node
    node = self.compose_sequence_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/composer.py", line 184, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/composer.py", line 142, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/composer.py", line 222, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/composer.py", line 142, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/composer.py", line 215, in compose_mapping_node
    while not self.parser.check_event(MappingEndEvent):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/parser.py", line 150, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/parser.py", line 636, in parse_block_mapping_key
    if self.scanner.check_token(KeyToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/scanner.py", line 1827, in check_token
    self._gather_comments()
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/scanner.py", line 1869, in _gather_comments
    self.fetch_more_tokens()
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/scanner.py", line 290, in fetch_more_tokens
    return self.fetch_value()
           ^^^^^^^^^^^^^^^^^^
  File "/home//src/github/redacted/scs/hardware-landscape/venv/lib/python3.12/site-packages/ruyaml/scanner.py", line 665, in fetch_value
    raise ScannerError(
ruyaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 26, column 21:
             echo "ERROR: not exactly on session available"
                        ^ (line: 26)

$ git diff ./environments/custom/roles/scs-serial-terminals/tasks/main.yml

....
diff --git a/environments/custom/roles/scs-serial-terminals/tasks/main.yml b/environments/custom/roles/scs-serial-terminals/tasks/main.yml
index 2339689..8677cb5 100644
--- a/environments/custom/roles/scs-serial-terminals/tasks/main.yml
+++ b/environments/custom/roles/scs-serial-terminals/tasks/main.yml
@@ -1,6 +1,5 @@
....
     content: |
-      #!/bin/bash
-
+        #!/bin/bash
       ident="scs_serial_access"
       cfg="/etc/screenrc_serial"
       logdir="/var/log/screen"
-

@scoopex scoopex added the bug Something isn't working label Jul 7, 2024
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

1 participant