Bug 1059305

Summary: RFE: make yaml file parsing bulletproof
Product: [Fedora] Fedora Reporter: Tomáš Bžatek <tbzatek>
Component: devassistantAssignee: Bohuslav "Slavek" Kabrda <bkabrda>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: low    
Version: rawhideCC: bkabrda, phracek, tsmetana
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: devassistant-0.9.3-2.fc22 devassistant-0.9.3-2.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-09 14:10:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
a yaml file that reproduces the problem none

Description Tomáš Bžatek 2014-01-29 15:42:28 UTC
Created attachment 857110 [details]
a yaml file that reproduces the problem

Description of problem:
Badly written yaml file may render devassistant unusable, getting python traceback instead of well described error that helps assistant author easily spot the error.

Version-Release number of selected component (if applicable):
devassistant-0.8.0-1.fc21.noarch

How reproducible:
always

Steps to Reproduce:
1. Place the attached file in ~/.devassistant/assistants/crt/c
2. da

Actual results:
Traceback (most recent call last):
  File "/usr/bin/da", line 9, in <module>
    load_entry_point('devassistant==0.8.0', 'console_scripts', 'da')()
  File "/usr/lib/python2.7/site-packages/devassistant/cli/cli_runner.py", line 44, in run
    tree = top_assistant.get_subassistant_tree()
  File "/usr/lib/python2.7/site-packages/devassistant/assistant_base.py", line 65, in get_subassistant_tree
    subassistant_tree.append(subassistant.get_subassistant_tree())
  File "/usr/lib/python2.7/site-packages/devassistant/assistant_base.py", line 63, in get_subassistant_tree
    subassistants = self.get_subassistants()
  File "/usr/lib/python2.7/site-packages/devassistant/bin.py", line 15, in get_subassistants
    sa = yaml_assistant_loader.YamlAssistantLoader.get_assistants(superassistants=[self])
  File "/usr/lib/python2.7/site-packages/devassistant/yaml_assistant_loader.py", line 25, in get_assistants
    cls.load_all_assistants(superassistants)
  File "/usr/lib/python2.7/site-packages/devassistant/yaml_assistant_loader.py", line 63, in load_all_assistants
    role=tl)
  File "/usr/lib/python2.7/site-packages/devassistant/yaml_assistant_loader.py", line 126, in get_assistants_from_file_hierarchy
    role=role)
  File "/usr/lib/python2.7/site-packages/devassistant/yaml_assistant_loader.py", line 120, in get_assistants_from_file_hierarchy
    role=role)
  File "/usr/lib/python2.7/site-packages/devassistant/yaml_assistant_loader.py", line 188, in assistant_from_yaml
    role=role)
  File "/usr/lib/python2.7/site-packages/devassistant/yaml_assistant.py", line 39, in __init__
    self.parsed_yaml = parsed_yaml
  File "/usr/lib/python2.7/site-packages/devassistant/yaml_assistant.py", line 52, in parsed_yaml
    self.args = self._construct_args(value.get('args', {}))
  File "/usr/lib/python2.7/site-packages/devassistant/yaml_assistant.py", line 91, in _construct_args
    for arg_name, arg_params in struct.items():
AttributeError: 'NoneType' object has no attribute 'items'


Additional info:
The error shows up right on "da" startup, suggesting it loads all the assistants even before processing the commandline.

Comment 1 Bohuslav "Slavek" Kabrda 2014-01-30 09:13:19 UTC
Thanks for the report, I fixed this in upstream commit [1]. Do you want me to backport the patch to current release or is it ok if we postpone this for next version?


[1] https://github.com/bkabrda/devassistant/commit/5f1d6681bcd7d3a11803098d8bd8fbb42efbebee

Comment 2 Tomáš Bžatek 2014-01-31 15:17:20 UTC
(In reply to Bohuslav "Slavek" Kabrda from comment #1)
> Thanks for the report, I fixed this in upstream commit [1]. Do you want me
> to backport the patch to current release or is it ok if we postpone this for
> next version?

Thanks, works like a charm now! No need for immediate backporting, I've patched the files locally. Besides, this is an easy-to-overcome issue.

Comment 3 Bohuslav "Slavek" Kabrda 2014-12-09 14:10:00 UTC
Fixed as of DevAssistant 0.9.0, e.g. F21 and later.