Skip to content

Traceback on yaml anchor #5

@MatthewScholefield

Description

@MatthewScholefield

When parsing a yaml file with an anchor, yaml2jsonnet generates a traceback:

$ cat anchor-example.yaml
foo: &foo-ref
  key-1: "val-1"
  key-2: "val-2"
var: *foo-ref
$ yaml2jsonnet anchor-example.yaml
Traceback (most recent call last):
  File "/home/user/.local/bin/yaml2jsonnet", line 8, in <module>
    sys.exit(main())
  File "/home/user/.local/lib/python3.9/site-packages/yaml2jsonnet/cli.py", line 58, in main
    run(args)
  File "/home/user/.local/lib/python3.9/site-packages/yaml2jsonnet/cli.py", line 47, in run
    convert_yaml(yaml_data, args.out, args.document_comments)
  File "/home/user/.local/lib/python3.9/site-packages/yaml2jsonnet/yaml2jsonnet.py", line 14, in convert_yaml
    JsonnetRenderer(events, output, array, inject_comments).render()
  File "/home/user/.local/lib/python3.9/site-packages/yaml2jsonnet/jsonnet_renderer.py", line 210, in render
    self.state.send(event)
  File "/home/user/.local/lib/python3.9/site-packages/yaml2jsonnet/jsonnet_renderer.py", line 383, in _mapping_value
    raise UnhandledEventError(self, event)
yaml2jsonnet.jsonnet_renderer.UnhandledEventError: Event was not handled by the current state: Last event was AliasEvent(anchor='foo-ref'), the state was _mapping_value, the queue was [(StreamStartEvent,_start), (DocumentStartEvent,_stream), (MappingStartEvent,_document)]

Instead it'd be nice to show an error like "Yaml anchors are not supported. Please remove them and try again."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions