nexB/aboutcode-toolkit

Error when getting license text and information when using `--api_url` and `--api_key` options

JonoYang opened this issue · 2 comments

I am generating an attribution report where I want to get license text and information from an API that provides license information. I am getting this error whenever I use the --api_url and --api_key options.

Command completed with 1 errors or warnings.
ERROR: : 'results'

This looks like a KeyError, but I'm not sure where this is happening.

The issue is with this line: https://github.com/nexB/aboutcode-toolkit/blob/develop/src/attributecode/api.py#L63

I've replaced the line with:

if not license_data.get('results', {}):

and reran about attrib and got the following errors:

Command completed with 90 errors or warnings.
ERROR: : Invalid 'license': proprietary-license
ERROR: : Invalid 'license': apache-2.0
ERROR: : Invalid 'license': gpl-2.0
ERROR: : Invalid 'license': bsd-new
ERROR: : Invalid 'license': mit
ERROR: : Invalid 'license': cc-by-3.0
ERROR: : Invalid 'license': lgpl-2.1
ERROR: : Invalid 'license': bsd-simplified
...

This error is actually caused by me not using the right API endpoint for license data, but the code should still be updated such that the correct error messages appear.