Skip to content
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

fix(slack): don't raise RuntimeError if unable to fetch property in slack request #67798

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/sentry/integrations/slack/requests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,20 @@ def integration(self) -> RpcIntegration:
return self._integration

@property
def channel_id(self) -> str:
def channel_id(self) -> str | None:
cathteng marked this conversation as resolved.
Show resolved Hide resolved
return get_field_id(self.data, "channel")
Copy link
Contributor

Choose a reason for hiding this comment

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

could we use _get_field_id_option here as well, or no? Wonder why it's different

Copy link
Member Author

Choose a reason for hiding this comment

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

we always expect a channel. i forgot to undo the type change


@property
def response_url(self) -> str:
return self.data.get("response_url", "")

@property
def team_id(self) -> str:
return get_field_id(self.data, "team")
def team_id(self) -> str | None:
return _get_field_id_option(self.data, "team")

@property
def user_id(self) -> str:
return get_field_id(self.data, "user")
def user_id(self) -> str | None:
return _get_field_id_option(self.data, "user")

@property
def data(self) -> Mapping[str, Any]:
Expand Down
1 change: 1 addition & 0 deletions tests/sentry/integrations/slack/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def test_none_in_data(self):
request.META = (options.get("slack.signing-secret"), self.request.body)

slack_request = SlackRequest(request)
assert slack_request.team_id is None
assert slack_request.logging_data == {
"slack_channel_id": "1",
"slack_user_id": "2",
Expand Down
Loading