Skip to content

feat(sentry apps): add urls to issue.created webhook #93780

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 8 commits into
base: master
Choose a base branch
from

Conversation

Christinarlong
Copy link
Contributor

per - #93404 & getsentry/sentry-docs#8992

We were missing urls in the issue.created webhooks despite docs saying we had them. This PR adds url, web_url & project_url according to the docs

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 18, 2025
@Christinarlong Christinarlong marked this pull request as ready for review June 18, 2025 15:54
@Christinarlong Christinarlong requested review from a team as code owners June 18, 2025 15:54
) -> WebhookGroupResponse:

webhook_payload = WebhookGroupResponse(
url=absolute_uri(f"/api/0/organizations/{group.organization.slug}/issues/{group.id}/"),
Copy link
Member

Choose a reason for hiding this comment

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

It would be a bit cleaner add this as another method on the group + follow the same conventions that get_absolute_url already does. Some of the stuff, like resolved /api/0/organizations is already available as a convenience method on the Organization model as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah good suggestion of adding the get_api_url option to Group .

I've added a p. basic one that follows the api docs but it also looks like get_absolute_url has some additional parameters/conventions it can expect which I;m not too familiar with/not sure if they need to be accounted for in the get_api_url method (I dont think so?)

/api/0/organizations is already available as a convenience method on the Organization model as well.

Can you point me to this part? I couldn't find seem to find it with a ctrl-shift-f /api/0/organizations

Copy link
Member

Choose a reason for hiding this comment

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

Oh you're right, we only have org helper methods for web URLs don't we? 😅 Should we add one? Seems pretty useful for other contexts too.

) -> WebhookGroupResponse:

webhook_payload = WebhookGroupResponse(
url=absolute_uri(f"/api/0/organizations/{group.organization.slug}/issues/{group.id}/"),
Copy link
Member

@iamrajjoshi iamrajjoshi Jun 18, 2025

Choose a reason for hiding this comment

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

maybe we use

def get_absolute_url(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we do use this in the below line for web_url but it'll get the website link so we need another way to get the api_url

Copy link

codecov bot commented Jun 18, 2025

Codecov Report

Attention: Patch coverage is 97.67442% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/models/group.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #93780      +/-   ##
==========================================
+ Coverage   81.66%   88.04%   +6.38%     
==========================================
  Files       10330    10337       +7     
  Lines      596288   596719     +431     
  Branches    23163    23163              
==========================================
+ Hits       486957   525380   +38423     
+ Misses     108875    70883   -37992     
  Partials      456      456              

Comment on lines +696 to +700
query = None
path = f"/issues/{self.id}/"
if params:
query = urlencode(params)
return self.organization.absolute_api_url(path=path, query=query)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need to include query params? The published endpoint doesn't look like it takes any? https://docs.sentry.io/api/events/retrieve-an-issue/ :/

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