Skip to content

Conversation

GabeVillalobos
Copy link
Member

Our current ticket creation errors are noisy. The majority of them are the result of strict configuration on the Jira site rejecting the ticket creation. These messages tend to vary greatly in content, and are generally unhelpful in triaging failing ticket creations.

This PR overrides the default error handling, and reraises the issues as IntegrationConfigurationErrors, which records them as halts instead of failures.

@GabeVillalobos GabeVillalobos requested review from a team as code owners September 22, 2025 23:52
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 22, 2025
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../sentry/notifications/notification_action/types.py 96.15% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #100078      +/-   ##
===========================================
+ Coverage   79.86%    81.19%   +1.32%     
===========================================
  Files        8576      8582       +6     
  Lines      380778    381037     +259     
  Branches    23963     23963              
===========================================
+ Hits       304127    309391    +5264     
+ Misses      76297     71292    -5005     
  Partials      354       354              

Comment on lines 983 to 989
if isinstance(exc, ApiInvalidRequestError):
if exc.json:
error_fields = self.error_fields_from_json(exc.json)
if error_fields is not None:
raise IntegrationFormError(error_fields).with_traceback(sys.exc_info()[2])
raise IntegrationConfigurationError(exc.text) from exc
super().raise_error(exc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we trying to target errors like this - Sentry Issue ? In that case, I don't think our ApiError logic is knowledgeable enough to translate to ApiInvalidRequest error yet?

Also also, for error_fields_from_json, I think we need to get rid of the regex matching or add some more(?) since it only matches on the Team Field currently. Or we could use error_message_from_json 🤔

cursor[bot]

This comment was marked as outdated.

# We need to reraise ProcessingDeadlineExceeded for workflow engine to
# monitor and potentially retry this action.
raise
except RETRIABLE_EXCEPTIONS as e:
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
except RETRIABLE_EXCEPTIONS as e:
except RETRYABLE_EXCEPTIONS as e:

Copy link
Member

Choose a reason for hiding this comment

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

Also, should these simply be reraised? I thought taskbroker would automatically retry unless the exception is in an exclude list

Copy link
Member Author

@GabeVillalobos GabeVillalobos Sep 30, 2025

Choose a reason for hiding this comment

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

Yeah that's fair. I'll change this. Remembering our office hours discussion on this: isn't this part of our contract with workflow engine? Depending on how this task gets executed, we may need to raise as this specific exception to make it obvious to top-level handling that we want an explicit retry.

Copy link
Member

Choose a reason for hiding this comment

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

I see

configuration problems, like required fields missing.
"""
if isinstance(exc, ApiInvalidRequestError):
if exc.json:
Copy link
Member

Choose a reason for hiding this comment

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

Is it reasonable to do more checking of the message like checking if "is required" is in the response from Jira (like adding to CUSTOM_ERROR_MESSAGE_MATCHERS)? I slightly worry about overreporting halts when they should be failures

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this seems overly permissive for now. 🤔 I can start by logging out the invalid response bodies, then creating a list to check against. The problem is, I've seen so many distinct error messages, including some that have HTML bodies, that it'll be impossible to string match against all of them.

cursor[bot]

This comment was marked as outdated.


logger.warning(
"sentry.jira.raise_error.api_invalid_request_error",
extra={
Copy link
Member

Choose a reason for hiding this comment

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

We could have exc.json but it didn't match the existing error fields. Should that be logged too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh this is a really good point. This could help us cut down on the XML/HTML junk we get back from Jira. I'll do that instead, ty!

responses.POST,
"https://example.atlassian.net/rest/api/2/issue",
status=400,
body=json.dumps({"error": "Jira had an oopsie"}),
Copy link
Member

Choose a reason for hiding this comment

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

oopsie

Comment on lines +841 to +843
invoke_future_with_error_handling(self.event_data, self.mock_callback, self.mock_futures)

self.mock_callback.assert_called_once_with(self.group_event, self.mock_futures)
Copy link
Member

Choose a reason for hiding this comment

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

TIL you can pass a Mock into a function and assert it got called 🤯

# We need to reraise ProcessingDeadlineExceeded for workflow engine to
# monitor and potentially retry this action.
raise
except RETRIABLE_EXCEPTIONS as e:
Copy link
Member

Choose a reason for hiding this comment

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

I see

@GabeVillalobos GabeVillalobos merged commit 134887b into master Oct 2, 2025
65 checks passed
@GabeVillalobos GabeVillalobos deleted the gv/silence-jira-invalid-request-errors branch October 2, 2025 19:42
Copy link

sentry-io bot commented Oct 2, 2025

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

  • ‼️ RetryError in prod

  • ‼️ [**IntegrationConfigurationError: {"errorMessages":"...** in prod

  • ‼️ [**IntegrationConfigurationError: {"errorMessages":"...** in prod

  • ‼️ [**IntegrationConfigurationError: {"errorMessages":"...** in prod

  • ‼️ RetryError in prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants