Skip to content

Commit 8c3b0a1

Browse files
committed
validation error 오류 UX 추가
1 parent 485a634 commit 8c3b0a1

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed

app.py

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import sentry_sdk
1212
from slack_bolt import App
13+
from pydantic import ValidationError
1314
from cachetools import cached, TTLCache
1415
from slack_bolt.adapter.socket_mode import SocketModeHandler
1516

@@ -321,10 +322,49 @@ def laas_jira(event, say, collection: PICollection):
321322
reporter_email = slack.user_map.get(slack.item_user, {}).get('email') or outside_slack_jira_user_map(slack.item_user)
322323
assignee_email = slack.user_map.get(slack.reaction_user, {}).get('email') or outside_slack_jira_user_map(slack.reaction_user)
323324

324-
issue = Issue.model_validate(gpt_metadata)
325+
try:
326+
issue = Issue.model_validate(gpt_metadata)
327+
except ValidationError:
328+
slack.say(
329+
channel=slack.reaction_user,
330+
blocks=[
331+
{
332+
"type": "header",
333+
"text": {
334+
"type": "plain_text",
335+
"text": "Jira 이슈 생성에 실패했습니다."
336+
}
337+
},
338+
{
339+
"type": "section",
340+
"text": {
341+
"type": "plain_text",
342+
"text": "이슈 타입별로 필수적인 필드가 있습니다. 필수 필드가 누락되지 않았는지 확인해보세요",
343+
}
344+
},
345+
{
346+
"type": "context",
347+
"elements": [
348+
{
349+
"type": "mrkdwn",
350+
"text": f"<{slack.link}|스레드 바로가기>"
351+
}
352+
]
353+
},
354+
{
355+
"type": "context",
356+
"elements": [
357+
{
358+
"type": "mrkdwn",
359+
"text": f"Error Message: ```{str(e)}```"
360+
}
361+
]
362+
},
363+
]
364+
)
365+
raise e
325366

326367
jira = JiraOperator()
327-
jira.get_user_id_from_email(assignee_email)
328368
refined_fields = issue.refined_fields(
329369
jira.get_user_id_from_email(reporter_email),
330370
jira.get_user_id_from_email(assignee_email),
@@ -348,7 +388,7 @@ def laas_jira(event, say, collection: PICollection):
348388
"type": "section",
349389
"text": {
350390
"type": "plain_text",
351-
"text": "이슈 타입별로 필수적인 필드가 있습니다. 필수 필드가 누락되지 않았는지 확인해보세요",
391+
"text": "Jira 설정이 변경되거나, 개발 오류일 수 있습니다.",
352392
}
353393
},
354394
{

middleware/laas/jira_fields_schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def refined_fields(self, reporter_id, assignee_id, slack_link):
7171
if self.issue_type == '버그':
7272
return {
7373
'project': {'key': 'PI'},
74-
'reporter': {'id': reporter_id},
75-
'assignee': {'id': assignee_id},
74+
'assignee': {'accountId': assignee_id},
75+
'reporter': {'accountId': reporter_id},
7676
'issuetype': {'name': self.issue_type},
7777
'description': self.description,
7878
'summary': self.summary,
@@ -84,8 +84,8 @@ def refined_fields(self, reporter_id, assignee_id, slack_link):
8484
else:
8585
return {
8686
'project': {'key': 'PI'},
87-
'reporter': {'id': reporter_id},
88-
'assignee': {'id': assignee_id},
87+
'assignee': {'accountId': assignee_id},
88+
'reporter': {'accountId': reporter_id},
8989
'issuetype': {'name': self.issue_type},
9090
'description': self.description,
9191
'summary': self.summary,

0 commit comments

Comments
 (0)