Skip to content

Commit

Permalink
🐛 fix: using ryan's helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrajjoshi committed Sep 23, 2024
1 parent f6ca079 commit 094a247
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/sentry/integrations/slack/webhooks/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,17 @@ def api_error(

return self.respond_ephemeral(text)

@staticmethod
def _unpack_error_text(validation_error: serializers.ValidationError) -> str:
detail = validation_error.detail
while True:
if isinstance(detail, dict):
detail = list(detail.values())
element = detail[0]
if isinstance(element, str):
return element
detail = element

def validation_error(
self,
slack_request: SlackActionRequest,
Expand All @@ -247,12 +258,7 @@ def validation_error(
},
)

text: str = ""
if isinstance(error.detail, dict):
text = list(*error.detail.values())[0]
else:
text = str(error.detail[0])

text: str = self._unpack_error_text(error)
return self.respond_ephemeral(text)

def on_assign(
Expand Down

0 comments on commit 094a247

Please sign in to comment.