Skip to content

🐛 fix(vsts): catch org integration not found errors in outbound status sync #92139

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iamrajjoshi
Copy link
Member

self.org_integration is a property that raises OrganizationIntegrationNotFound it doesn't exist.

we didn't catch this exception and recorded this as a failure, even though this should mean we don't sync outbound.

this patch will not attempt to sync the status if the org integration can't be found. it will improve SLOs and save resources

@iamrajjoshi iamrajjoshi self-assigned this May 22, 2025
@iamrajjoshi iamrajjoshi requested review from a team as code owners May 22, 2025 17:58
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 22, 2025
@@ -379,13 +380,18 @@ class IssueSyncIntegration(IssueBasicIntegration, ABC):

def should_sync(self, attribute: str, sync_source: AssignmentSource | None = None) -> bool:
key = getattr(self, f"{attribute}_key", None)
if key is None or self.org_integration is None:
try:
org_integration = self.org_integration
Copy link
Member

@sentaur-athena sentaur-athena May 22, 2025

Choose a reason for hiding this comment

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

It's ok for this method to return false because it means we don't sync. But why is it even being called if there is no installation? I think the fix should be not call any of these methods actually if the org_integration throws exception.

Copy link
Member Author

@iamrajjoshi iamrajjoshi May 22, 2025

Choose a reason for hiding this comment

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

But why is it even being called if there is no installation

this is happening because the org links an issue, then deletes the integration which leaves us in this state. i was considering deleting the link itself, but that would mean the user doesn't see the link in the UI which might raise more questions

Copy link
Member Author

Choose a reason for hiding this comment

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

the task is triggered on a status update here: https://github.com/getsentry/sentry/blob/cb9f7e87657583b0f766c460c840c5e3fac816d3/src/sentry/integrations/tasks/kick_off_status_syncs.py#L25-L37

this should_sync method is the main gate which checks whether:

  1. the integration id to make sure we don't have cyclic syncs
  2. makes sure that the status sync feature is enabled

imo, this method is a good place checking if the org integration exists. i didn't want to do it 1 level higher since that would mean we would need to deal with integration/orgintegration level concerns when kicking off the async task.

Copy link
Member Author

Choose a reason for hiding this comment

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

that being said, i can move this around if we think its better

Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

⚠️ Parser warning

The parser emitted a warning. Please review your JUnit XML file:

Warning while parsing testcase attributes: Limit of string is 1000 chars, for name, we got 2083 at 1:156615 in /home/runner/work/sentry/sentry/.artifacts/pytest.junit.xml
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #92139       +/-   ##
===========================================
+ Coverage   41.74%   87.86%   +46.12%     
===========================================
  Files       10152    10179       +27     
  Lines      582428   583525     +1097     
  Branches    22632    22632               
===========================================
+ Hits       243120   512728   +269608     
+ Misses     338856    70345   -268511     
  Partials      452      452               

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.

2 participants