Skip to content

fix: add get_issue_safe to repo client #816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
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
13 changes: 13 additions & 0 deletions src/codegen/git/clients/git_repo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ def get_pull_safe(self, number: int) -> PullRequest | None:
logger.warning(f"Error getting PR by number: {number}\n\t{e}")
return None

def get_issue_safe(self, number: int) -> Issue | None:
"""Returns an issue by its number
TODO: catching UnknownObjectException is common enough to create a decorator
"""
try:
pr = self.repo.get_issue(number)
return pr
except UnknownObjectException as e:
return None
except Exception as e:
logger.warning(f"Error getting issue by number: {number}\n\t{e}")
return None

def get_or_create_pull(
self,
head_branch_name: str,
Expand Down
Loading