Skip to content

More descriptive error messages #311

@starlightromero

Description

@starlightromero

Description

It would be helpful to have more descriptive error messaging instead of the python traceback:

Traceback (most recent call last):
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/bin/yamlfix", line 7, in <module>
    sys.exit(cli())
             ~~~^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/yamlfix/entrypoints/cli.py", line 141, in cli
    fixed_code, changed = services.fix_files(files_to_fix, check, config)
                          ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/yamlfix/services.py", line 82, in fix_files
    fixed_source = fix_code(source, config)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/yamlfix/services.py", line 161, in fix_code
    source_code = fixer.fix(source_code=source_code)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/yamlfix/adapters.py", line 363, in fix
    source_code = fixer(source_code)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/yamlfix/adapters.py", line 381, in _ruamel_yaml_fixer
    for source_dict in source_dicts:
                       ^^^^^^^^^^^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/main.py", line 477, in load_all
    yield constructor.get_data()
          ~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/constructor.py", line 134, in get_data
    return self.construct_document(self.composer.get_node())
                                   ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 63, in get_node
    return self.compose_document()
           ~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 96, in compose_document
    node = self.compose_node(None, None)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 142, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 222, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 142, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 222, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 142, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 222, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 140, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/composer.py", line 183, in compose_sequence_node
    while not self.parser.check_event(SequenceEndEvent):
              ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/parser.py", line 150, in check_event
    self.current_event = self.state()
                         ~~~~~~~~~~^^
  File "/Users/starlightromero/.asdf/installs/python/3.13.1/lib/python3.13/site-packages/ruyaml/parser.py", line 577, in parse_block_sequence_entry
    raise ParserError(
    ...<4 lines>...
    )
ruyaml.parser.ParserError: while parsing a block collection
  in "<unicode string>", line 6, column 7:
          - uses: actions/stale@v10
          ^ (line: 6)
expected <block end>, but found '?'
  in "<unicode string>", line 7, column 7:
          with:
          ^ (line: 7)

Steps to reproduce

  1. Run yamlfix with some error
  2. See traceback

Current behavior

Long traceback

Desired behavior

Clear error message that I can understand what to fix

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions