Skip to content

Conversation

@cathteng
Copy link
Member

@cathteng cathteng commented Oct 31, 2025

How unfurl works:

  • We receive a link_shared webhook, which can contain multiple links
  • (new SLO) We parse each link and determine whether we can unfurl it -- it has to be a certain type (discover, metric alert, issue)
  • (existing SLO for each unfurlable link type) We generate the unfurl payload
  • (existing SLO) We hit the Slack chat.unfurl endpoint to display the payload for the message

@cathteng cathteng requested review from a team as code owners October 31, 2025 18:36
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 31, 2025
@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 94.33962% with 3 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/integrations/slack/webhooks/event.py 93.18% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #102500      +/-   ##
===========================================
+ Coverage   80.89%    80.91%   +0.01%     
===========================================
  Files        8847      8850       +3     
  Lines      390072    390290     +218     
  Branches    24812     24812              
===========================================
+ Hits       315559    315788     +229     
+ Misses      74148     74137      -11     
  Partials      365       365              

@cathteng cathteng changed the title chore(slack): update unfurl SLO to cover all function logic chore(slack): reorganize unfurl SLOs Oct 31, 2025
Comment on lines 169 to 183
ois = integration_service.get_organization_integrations(
integration_id=slack_request.integration.id, limit=1
)
organization_id = ois[0].organization_id if len(ois) > 0 else None
organization_context = (
organization_service.get_organization_by_id(
id=organization_id,
user_id=None,
include_projects=False,
include_teams=False,
)
if organization_id
else None
)
organization = organization_context.organization if organization_context else None
Copy link
Member

Choose a reason for hiding this comment

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

Is this organization ID actually useful for us? We're only pulling the first org ID, which may or may not even belong to this region.

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 only thing it's used for is to determine if somebody is pasting a discover link and asking them to link their identity if necessary

if (
organization
and link_type == LinkType.DISCOVER
and not slack_request.has_identity
and features.has(
"organizations:discover-basic", organization, actor=request.user
)
):

I'm not sure of a good replacement for this logic that doesn't use organization

cursor[bot]

This comment was marked as outdated.


# Link can't be unfurled
if link_type is None or args is None:
lifecycle.record_halt("Unfurlable link", extra={"url": url})
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Cannot unfurl: misleading halt message under None conditions

The halt message "Unfurlable link" is misleading. This message is recorded when link_type is None or args is None, which means the link CANNOT be unfurled. The message should say something like "Cannot unfurl link" or "Non-unfurlable link" to accurately reflect the condition being checked.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

bruh

Copy link
Member

@GabeVillalobos GabeVillalobos left a comment

Choose a reason for hiding this comment

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

Changes seem fine, but we probably want some more refactors in the future to handle more of these error cases

)
url = item["url"]
except Exception:
lifecycle.record_failure("Failed to parse link", extra={**logger_params})
Copy link
Member

Choose a reason for hiding this comment

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

This try/except is sort of weird. Realistically, this should only ever be a key error, and we can probably handle it a bit more gracefully with a None check 🤔

@cathteng cathteng merged commit 4d89c10 into master Nov 4, 2025
70 of 72 checks passed
@cathteng cathteng deleted the cathy/slack/fix-unfurl-slo branch November 4, 2025 00:01
@sentry
Copy link

sentry bot commented Nov 4, 2025

Issues attributed to commits in this pull request

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

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