esunar / test4

GNU General Public License v3.0
0 stars 0 forks source link

"KeyError" raised if subordinate charm is not included in the rule file #203

Open esunar opened 1 year ago

esunar commented 1 year ago

When an extra or optional subordinate charm is not included in the rule file, juju-lint failed with "KeyError", for example:

Traceback (most recent call last): File "/snap/juju-lint/68/bin/juju-lint", line 8, in sys.exit(main()) File "/snap/juju-lint/current/lib/python3.8/site-packages/jujulint/cli.py", line 193, in main cli.audit_file(cli.manual_file, cloud_type=cli.cloud_type) File "/snap/juju-lint/current/lib/python3.8/site-packages/jujulint/cli.py", line 126, in audit_file linter.lint_yaml_file(filename) File "/snap/juju-lint/current/lib/python3.8/site-packages/jujulint/lint.py", line 1223, in lint_yaml_file return self.do_lint(parsed_yaml) File "/snap/juju-lint/current/lib/python3.8/site-packages/jujulint/lint.py", line 1251, in do_lint self.process_subordinates(parsed_yaml[applications][app], app) File "/snap/juju-lint/current/lib/python3.8/site-packages/jujulint/lint.py", line 167, in process_subordinates allow_multiple = self.lint_rules["subordinates"][charm].get( KeyError: 'sysconfig'

I think this kind of error should be handled gracefully. Either ignore the extra subordinate charms (i.e. consider them as optional) or raise more interpretable error other than a "KeyError".


Imported from Launchpad using lp2gh.