-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(github): Add issue types support for Sentry issues #111501
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
base: master
Are you sure you want to change the base?
Changes from all commits
5f10e62
e7d86bd
f6c461d
0079f5c
524bbea
a4d1642
e975279
7a73f6e
4d34013
612e34b
ffc3773
9bd2a32
ce9b55c
b5d1321
f77a54b
f627022
07ac07d
11ce58d
b196a68
e7e136f
f4dd3e1
f958f03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,9 +180,14 @@ def get_create_issue_config( | |
|
|
||
| assignees = self.get_allowed_assignees(default_repo) if default_repo else [] | ||
| labels: Sequence[tuple[str, str]] = [] | ||
| issue_types: Sequence[tuple[str, str]] = [] | ||
| if default_repo: | ||
| owner, repo = default_repo.split("/") | ||
| labels = self.get_repo_labels(owner, repo) | ||
| try: | ||
| issue_types = self.get_org_issue_types(owner) | ||
| except IntegrationResourceNotFoundError: | ||
| issue_types = [] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-404 errors from issue types API crash formMedium Severity The Additional Locations (1) |
||
|
|
||
| autocomplete_url = reverse( | ||
| "sentry-integration-github-search", args=[org.slug, self.model.id] | ||
|
|
@@ -217,6 +222,15 @@ def get_create_issue_config( | |
| "required": False, | ||
| "choices": labels, | ||
| }, | ||
| { | ||
| "name": "type", | ||
| "label": "Type", | ||
| "default": "", | ||
| "type": "select", | ||
| "multiple": False, | ||
| "required": False, | ||
| "choices": issue_types, | ||
| }, | ||
| ] | ||
|
|
||
| def create_issue(self, data: Mapping[str, Any], **kwargs: Any) -> Mapping[str, Any]: | ||
|
|
@@ -253,6 +267,8 @@ def create_issue(self, data: Mapping[str, Any], **kwargs: Any) -> Mapping[str, A | |
| issue_data["assignee"] = data["assignee"] | ||
| if data.get("labels"): | ||
| issue_data["labels"] = data["labels"] | ||
| if data.get("type"): | ||
| issue_data["type"] = data["type"] | ||
|
|
||
| try: | ||
| issue = client.create_issue(repo=repo, data=issue_data) | ||
|
|
@@ -373,15 +389,34 @@ def get_repo_labels(self, owner: str, repo: str) -> Sequence[tuple[str, str]]: | |
| except Exception as e: | ||
| self.raise_error(e) | ||
|
|
||
| def natural_sort_pair(pair: tuple[str, str]) -> list[str | int]: | ||
| return [ | ||
| int(text) if text.isdecimal() else text.lower() | ||
| for text in re.split("([0-9]+)", pair[0]) | ||
| ] | ||
|
|
||
| # sort alphabetically | ||
| labels = tuple( | ||
| sorted([(label["name"], label["name"]) for label in response], key=natural_sort_pair) | ||
| sorted( | ||
| [(label["name"], label["name"]) for label in response], key=self.natural_sort_pair | ||
| ) | ||
| ) | ||
|
|
||
| return labels | ||
|
|
||
| def get_org_issue_types(self, owner: str) -> Sequence[tuple[str, str]]: | ||
| client = self.get_client() | ||
| try: | ||
| response = client.get_org_issue_types(owner) | ||
| except Exception as e: | ||
| self.raise_error(e) | ||
|
|
||
| # sort alphabetically | ||
| types = tuple( | ||
| sorted( | ||
| [(type_obj["name"], type_obj["name"]) for type_obj in response], | ||
| key=self.natural_sort_pair, | ||
| ) | ||
| ) | ||
|
|
||
| return types | ||
|
|
||
| def natural_sort_pair(self, pair: tuple[str, str]) -> list[str | int]: | ||
| return [ | ||
| int(text) if text.isdecimal() else text.lower() | ||
| for text in re.split("([0-9]+)", pair[0]) | ||
| ] | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The exception handling for
get_org_issue_typesis too narrow, only catchingIntegrationResourceNotFoundError. Other API errors, like 403s, will cause uncaught exceptions and crash callers.Severity: HIGH
Suggested Fix
Broaden the exception handler to catch
IntegrationErrorin addition to or instead ofIntegrationResourceNotFoundError. This will gracefully handle other expected API errors like 403 Forbidden (IntegrationConfigurationError) and fall back to an empty list as intended.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.