blackducksoftware / hub-rest-api-python

HUB REST API Python bindings
Apache License 2.0
89 stars 104 forks source link

KeyError: 'versionName' #192

Closed cint2021 closed 3 years ago

cint2021 commented 3 years ago

HI,

Without any changes we are receiving the message KeyError: 'versionName' when running scans using comand like docker run --rm registry.imagesXXXX.com/il-blackduck-api:latest validate_project_by_scan_name.py -n project-name

result: scanVersion = obj['versionName'] KeyError: 'versionName'

validate_project_by_scan_name.txt

version used : VERSION = (0, 0, 56) version = '.'.join(map(str, VERSION))

Any changes around the APIs regards?

cint2021 commented 3 years ago

maybe some structures was changed:

logging.debug(code_location['name']) sections = urlparse(code_location['mappedProjectVersion']) data = sections.path.split("/") project = data[3] version = data[5] obj = hub.get_version_by_id("/"+project,version) print(obj)

returns:

{​​​​​​'timestamp': '2021-08-18T12:03:31.111Z', 'status': 500, 'error': 'Internal Server Error', 'message': 'The request was rejected because the URL was not normalized.', 'path': '/api/projects//7c9f1837-9f92-43dd-8f4a-02c5dbdf9245/versions/c589b07e-ab87-4f28-8d41-d9dc9d494246'}​​​​​​
OffBy0x01 commented 3 years ago

The above is complaining because of the slash you are adding to the url on this line obj = hub.get_version_by_id("/"+project,version) The url constuction for that method looks like this: self._get_projects_url() + "/" + project_id + "/versions/" + version_id So you should only need: obj = hub.get_version_by_id(project,version)

There was a (now fixed) bug in significantly older versions where you needed to pass the slash.

cint2021 commented 3 years ago

thanks Andrew, this fixed it; appreciated your time

cint2021 commented 3 years ago

case closed