Skip to content

Findsources fails on invalid GitHub API response (KeyError: 'url') #203

@raahed

Description

@raahed

Hey,

We encountered an issue when Findsources fetches data from GitHub and receives an invalid response from github_request() in GitHubSupport, such as [{'message': 'Server Error'}]. The function get_matching_source_url() cannot handle this GitHub response properly.

At this point, I cannot say why we are getting a server error. However, the GitHubSupport class should raise an exception or retry the request, similar to how it behaves when the rate limit is reached (429 code). In case of an error response, it should, for example, call raise_for_status() from the requests library.

Below is the full stack trace:

ERROR: failed to run command capycli bom Findsources -v -i {..}/sw360_sbom.json -o {..}/final_sbom.json -gt [MASKED] with error Traceback (most recent call last):
  File "/usr/local/bin/capycli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/capycli/main/cli.py", line 28, in main
    app.run(argv)
  File "/usr/local/lib/python3.12/site-packages/capycli/main/application.py", line 159, in run
    self._run(argv)
  File "/usr/local/lib/python3.12/site-packages/capycli/main/application.py", line 140, in _run
    handle_bom.run_bom_command(self.options)
  File "/usr/local/lib/python3.12/site-packages/capycli/bom/handle_bom.py", line 129, in run_bom_command
    app12.run(args)
  File "/usr/local/lib/python3.12/site-packages/capycli/bom/findsources.py", line 794, in run
    found_count, exist_count = self.find_sources(sbom)
                               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/capycli/bom/findsources.py", line 705, in find_sources
    source_url = self.find_github_url(component)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/capycli/bom/findsources.py", line 337, in find_github_url
    source_url = self.get_matching_source_url(component.version, match["tags_url"])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/capycli/bom/findsources.py", line 285, in get_matching_source_url
    'zipball_url': tag['url'].replace(
                   ~~~^^^^^^^
KeyError: 'url'

Best
Marvin

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions