Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 726ea02

Browse files
thegreydlocriandev
andauthored
Ignore when new jira bugs are not found in ET (#535)
Co-authored-by: Daniele Paolella <[email protected]>
1 parent 505d12f commit 726ea02

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

elliottlib/bzutil.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ async def filter_attached_bugs(self, bugs: Iterable):
702702
bugs = list(bugs)
703703
api = AsyncErrataAPI()
704704
await api.login()
705-
results = await asyncio.gather(*[api.get_advisories_for_jira(bug.id) for bug in bugs])
705+
results = await asyncio.gather(*[api.get_advisories_for_jira(bug.id, ignore_not_found=True) for bug in bugs])
706706
attached_bugs = [bug for bug, advisories in zip(bugs, results) if advisories]
707707
await api.close()
708708
return attached_bugs

elliottlib/errata_async.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import base64
33
from typing import Dict, Iterable, List, Set, Union
44
from urllib.parse import quote, urlparse
5+
from aiohttp import ClientResponseError
56

67
import aiohttp
78
import gssapi
@@ -91,9 +92,19 @@ async def delete_cve_package_exclusion(self, exclusion_id: int):
9192
await self._make_request(aiohttp.hdrs.METH_DELETE, path, parse_json=False)
9293

9394
@limit_concurrency(limit=16)
94-
async def get_advisories_for_jira(self, jira_key: str):
95+
async def get_advisories_for_jira(self, jira_key: str, ignore_not_found=False):
9596
path = f"/jira_issues/{quote(jira_key)}/advisories.json"
96-
return await self._make_request(aiohttp.hdrs.METH_GET, path)
97+
try:
98+
result = await self._make_request(aiohttp.hdrs.METH_GET, path)
99+
except ClientResponseError as e:
100+
# When newly created jira bugs are not sync'd to ET we get a 404,
101+
# assume that they are not attached to any advisory
102+
if ignore_not_found and e.status == 404:
103+
result = []
104+
else:
105+
raise
106+
return result
107+
97108

98109
@limit_concurrency(limit=16)
99110
async def get_advisories_for_bug(self, bz_key: str):

0 commit comments

Comments
 (0)