Skip to content

chore(jira): Add more logs/expose them better #92359

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 6 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 6 additions & 2 deletions src/sentry/integrations/jira/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,24 +1006,28 @@ def sync_assignee_outbound(
extra={
"integration_id": external_issue.integration_id,
"user_id": user.id,
"user_emails": user.emails,
"issue_key": external_issue.key,
"organization_id": external_issue.organization_id,
},
)
return
raise IntegrationFormError({"email": "Unable to find the requested user"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntegrationFormError is generally for misconfigured ticket/sentry app forms. is there a more relevant type of error we can raise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the existing exceptions I see we have we could do IntegrationInstallationConfigurationError since this usually means the user either isnt verified or put a bad email/jira user.

I can narrow down the error message to be more helpful though if the user isn;t verified on sentry's side.

try:
id_field = client.user_id_field()
client.assign_issue(external_issue.key, jira_user and jira_user.get(id_field))
except (ApiUnauthorized, ApiError):
except (ApiUnauthorized, ApiError) as e:
# TODO(jess): do we want to email people about these types of failures?
logger.info(
"jira.failed-to-assign",
exc_info=e,
extra={
"organization_id": external_issue.organization_id,
"integration_id": external_issue.integration_id,
"user_id": user.id if user else None,
"issue_key": external_issue.key,
},
)
raise

def sync_status_outbound(
self, external_issue: ExternalIssue, is_resolved: bool, project_id: int
Expand Down
5 changes: 3 additions & 2 deletions tests/sentry/integrations/jira/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from sentry.integrations.services.integration import integration_service
from sentry.models.grouplink import GroupLink
from sentry.models.groupmeta import GroupMeta
from sentry.shared_integrations.exceptions import IntegrationError
from sentry.shared_integrations.exceptions import IntegrationError, IntegrationFormError
from sentry.silo.base import SiloMode
from sentry.testutils.cases import APITestCase, IntegrationTestCase
from sentry.testutils.factories import EventType
Expand Down Expand Up @@ -824,7 +824,8 @@ def test_sync_assignee_outbound_no_email(self):
"https://example.atlassian.net/rest/api/2/user/assignable/search",
json=[{"accountId": "deadbeef123", "displayName": "Dead Beef"}],
)
installation.sync_assignee_outbound(external_issue, user)
with pytest.raises(IntegrationFormError):
installation.sync_assignee_outbound(external_issue, user)

# No sync made as jira users don't have email addresses
assert len(responses.calls) == 1
Expand Down
Loading