in jbi/bugzilla/client.py [0:0]
def get_bug(self, bugid) -> Bug:
"""Retrieve details about the specified bug id."""
# https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#rest-single-bug
url = f"{self.base_url}/rest/bug/{bugid}"
try:
bug_info = self._call("GET", url)
except requests.HTTPError as err:
if err.response is not None and err.response.status_code in (401, 403, 404):
if self.logged_in():
# If bug returns 401 and credentials are valid.
msg = err.response.json().get("message", "bug not accessible")
raise BugNotAccessibleError(msg)
raise
parsed = ApiResponse.model_validate(bug_info)
if not parsed.bugs:
raise BugzillaClientError(
f"Unexpected response content from 'GET {url}' (no 'bugs' field)"
)
bug = parsed.bugs[0]
# If comment is private, then fetch it from server
if bug.comment and bug.comment.is_private:
comment_list = self.get_comments(bugid)
matching_comments = [c for c in comment_list if c.id == bug.comment.id]
# If no matching entry is found, set `bug.comment` to `None`.
found = matching_comments[0] if matching_comments else None
bug = bug.model_copy(update={"comment": found}, deep=True)
return bug