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

Use of aliases in a yaml file #222

Open
jburnich opened this issue Feb 7, 2023 · 1 comment
Open

Use of aliases in a yaml file #222

jburnich opened this issue Feb 7, 2023 · 1 comment
Labels
bug Something isn't working upstream

Comments

@jburnich
Copy link

jburnich commented Feb 7, 2023

Description

I have a yaml file with this format :

name: &alias key
*alias: value

which correspond to :

name: key
key: value

I have the following error:

[+] YamlFix: Fixing files
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "/home/jordan/.local/bin/yamlfix", line 8, in <module>
    sys.exit(cli())
  File "/home/jordan/.local/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/jordan/.local/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/jordan/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jordan/.local/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/jordan/.local/lib/python3.8/site-packages/yamlfix/entrypoints/cli.py", line 86, in cli
    fixed_code, changed = services.fix_files(files_to_fix, check, config)
  File "/home/jordan/.local/lib/python3.8/site-packages/yamlfix/services.py", line 82, in fix_files
    fixed_source = fix_code(source, config)
  File "/home/jordan/.local/lib/python3.8/site-packages/yamlfix/services.py", line 154, in fix_code
    source_code = fixer.fix(source_code=source_code)
  File "/home/jordan/.local/lib/python3.8/site-packages/yamlfix/adapters.py", line 362, in fix
    source_code = fixer(source_code)
  File "/home/jordan/.local/lib/python3.8/site-packages/yamlfix/adapters.py", line 380, in _ruamel_yaml_fixer
    for source_dict in source_dicts:
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/main.py", line 477, in load_all
    yield constructor.get_data()
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/constructor.py", line 134, in get_data
    return self.construct_document(self.composer.get_node())
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/composer.py", line 63, in get_node
    return self.compose_document()
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/composer.py", line 96, in compose_document
    node = self.compose_node(None, None)
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/composer.py", line 142, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/composer.py", line 215, in compose_mapping_node
    while not self.parser.check_event(MappingEndEvent):
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/parser.py", line 150, in check_event
    self.current_event = self.state()
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/parser.py", line 636, in parse_block_mapping_key
    if self.scanner.check_token(KeyToken):
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/scanner.py", line 1826, in check_token
    self.fetch_more_tokens()
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/scanner.py", line 240, in fetch_more_tokens
    return self.fetch_stream_end()
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/scanner.py", line 462, in fetch_stream_end
    self.remove_possible_simple_key()
  File "/home/jordan/.local/lib/python3.8/site-packages/ruyaml/scanner.py", line 401, in remove_possible_simple_key
    raise ScannerError(
ruyaml.scanner.ScannerError: while scanning a simple key
  in "<unicode string>", line 2, column 1:
    *alias: value
    ^ (line: 2)
could not find expected ':'
  in "<unicode string>", line 2, column 14:
    *alias: value
                 ^ (line: 2)
@jburnich jburnich added the bug Something isn't working label Feb 7, 2023
@lyz-code
Copy link
Owner

lyz-code commented Feb 7, 2023

I can reproduce the error, but the error looks to be from the upstream library ruyaml. Can you open an issue too on their repo and link it here?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

2 participants