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

Exceptions on malformed yaml #37

Closed
jayvdb opened this issue Jun 5, 2018 · 9 comments
Closed

Exceptions on malformed yaml #37

jayvdb opened this issue Jun 5, 2018 · 9 comments

Comments

@jayvdb
Copy link
Member

jayvdb commented Jun 5, 2018

I forgot to add a template after a target

targets:
  - .gitignore:

And got

  File "/home/jayvdb/.local/lib/python3.6/site-packages/jinja2/loaders.py", line 27, in split_template_path
    for piece in template.split('/'):
AttributeError: 'NoneType' object has no attribute 'split'

I suspect there are a few other similar cases of exceptions when given malformed yaml. moban should explain which line is broken and why.

@chfw
Copy link
Member

chfw commented Jul 15, 2018

Yes it will be user friendly

@seeeturtle
Copy link
Collaborator

@jayvdb @chfw
To report the exact position where it's wrong, yaml parser that supports line number is required.
However, pyyaml doesn't supports the feature. I can do some hacky things to make it support,
but there is already better library ruamel.yaml that supports it.
Is it ok to use ruamel.yaml instead of pyyaml?
Or should I do the hacky job?

@chfw
Copy link
Member

chfw commented Nov 30, 2018

looking from ruamel.yaml's change log and overview, it looks better. My instance is: if our unit tests above passes, I would give ruame.yaml a go.

@seeeturtle
Copy link
Collaborator

yup, it passes the test.
I'll work with the ruamek.yaml

seeeturtle added a commit to seeeturtle/moban that referenced this issue Dec 2, 2018
If empty value is found in mobanfile, moban will report the
line number of that.

Closes moremoban#37
seeeturtle added a commit to seeeturtle/moban that referenced this issue Dec 2, 2018
If empty value is found in mobanfile, moban will report the
line number of that.

Closes moremoban#37
seeeturtle added a commit to seeeturtle/moban that referenced this issue Dec 2, 2018
If empty value is found in mobanfile, moban will report the
line number of that.

Closes moremoban#37
seeeturtle added a commit to seeeturtle/moban that referenced this issue Dec 2, 2018
If empty value is found in mobanfile, moban will report the
line number of that and the name of the file.

Closes moremoban#37
seeeturtle added a commit to seeeturtle/moban that referenced this issue Dec 2, 2018
If empty value is found in mobanfile, moban will report the
line number of that and the name of the file.

Closes moremoban#37
seeeturtle added a commit to seeeturtle/moban that referenced this issue Dec 4, 2018
If empty value is found in mobanfile, moban will report the
line number of that and the name of the file.

Closes moremoban#37
@chfw chfw closed this as completed in #139 Dec 10, 2018
@chfw chfw mentioned this issue Dec 10, 2018
ayan-b pushed a commit to ayan-b/moban that referenced this issue Jan 15, 2019
ayan-b pushed a commit to ayan-b/moban that referenced this issue Jan 15, 2019
If empty value is found in mobanfile, moban will report the
line number of that and the name of the file.

Closes moremoban#37
@chfw
Copy link
Member

chfw commented Feb 7, 2019

Interesting, pyyaml can denote error location

  File "/Users/jaska/github/moremoban/moban-env/lib/python3.6/site-packages/yaml/constructor.py", line 414, in construct_undefined
    node.start_mark)
yaml.constructor.ConstructorError: could not determine a constructor for the tag '!copy'
  in ".moban.yml", line 5, column 5

pyyaml==3.13

@seeeturtle
Copy link
Collaborator

Yeah, pyyaml shows that in doc. It's quite strange that pyyaml doesn't give that to dev.

@chfw
Copy link
Member

chfw commented Feb 7, 2019

Meaning to the exception?

@seeeturtle
Copy link
Collaborator

i mean that pyyaml doesn't give location in general, even though they provide it in exception.

@seeeturtle
Copy link
Collaborator

Hmm... i've read pyyaml api and it seems to provide point of each element but not so convenient.
it provides some kind of ast for yaml file and tokens. they have location properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants