Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/psrt_ghsa_bot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from dotenv import load_dotenv
from githubkit import AppAuthStrategy, GitHub
from githubkit.exception import RequestFailed, RequestError
from requests.exceptions import RequestException

from psrt_ghsa_bot._sentry_monitoring import (
MONITOR_SLUG_GHSA,
Expand Down Expand Up @@ -213,7 +214,7 @@ def iter_cve_refs_with_tags(cve_api: CveApi, cve_id: str, tags: set[str]) -> abc
cve = cve_api.show_cve_record(cve_id)
cve_state = cve["cveMetadata"]["state"]
cve_refs = cve["containers"]["cna"]["references"]
except KeyError, RequestFailed, TypeError:
except KeyError, RequestException, TypeError:
# If we got a bad response, we can still proceed with other updates.
# Record the failure and continue.
# Note TypeError covers tests where cve_api is a mock without a
Expand Down
18 changes: 18 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from unittest import mock

import pytest
import requests.exceptions as req_exc

from psrt_ghsa_bot import app

Expand Down Expand Up @@ -549,3 +550,20 @@ def test_only_draft_ghsa_closed_on_cve(show_cve_response, state) -> None:
pass # We're testing the state didn't change, so no update is good.
else:
assert new_state == state


@pytest.mark.parametrize(
"errcls",
[
req_exc.RequestException,
req_exc.HTTPError,
req_exc.ConnectionError,
req_exc.ConnectTimeout,
req_exc.ReadTimeout,
],
)
def test_show_cve_errors_ignored(errcls, cve_id):
cve_api = mock.Mock()
cve_api.show_cve_record.side_effect = errcls("test error")
assert list(app.iter_cve_refs_with_tags(cve_api, cve_id, {"patch"})) == []
cve_api.show_cve_record.assert_called()
Loading