Skip to content
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
29 changes: 18 additions & 11 deletions src/sentry/integrations/msteams/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,17 +490,24 @@ def _issue_state_change(self, group: Group, identity: RpcIdentity, data) -> Resp
with MessagingInteractionEvent(
interaction_type, MsTeamsMessagingSpec()
).capture() as lifecycle:
response = client.put(
path=f"/projects/{group.project.organization.slug}/{group.project.slug}/issues/",
params={"id": group.id},
data=action_data,
user=user_service.get_user(user_id=identity.user_id),
auth=event_write_key,
)
if response.status_code == 403:
lifecycle.record_halt(response)
elif response.status_code >= 400:
lifecycle.record_failure(response)
try:
response = client.put(
path=f"/projects/{group.project.organization.slug}/{group.project.slug}/issues/",
params={"id": group.id},
data=action_data,
user=user_service.get_user(user_id=identity.user_id),
auth=event_write_key,
)
except client.ApiError as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

curious Q is there a difference between client.ApiError vs ApiError?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a different ApiError, the one we usually use is from shared_exceptions, so we need to annotate client here

if e.status_code == 403:
lifecycle.record_halt(e)
# If the user hasn't configured their releases properly, we recieve errors like:
# sentry.api.client.ApiError: status=400 body={'statusDetails': {'inNextRelease': [xxx])]}}"
# We can mark these as halt
elif e.status_code == 400 and e.body.get("statusDetails", {}).get("inNextRelease"):
lifecycle.record_halt(e)
elif e.status_code >= 400:
lifecycle.record_failure(e)
Comment on lines +509 to +510
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: thoughts on letting the error through and triggering the lifecycle/recording failure on its own ? (Curious on your thoughts since I've seen both ways)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think its stylistic atp

return response

def _handle_action_submitted(self, request: Request) -> Response:
Expand Down
Loading