Skip to content

Commit ec141b6

Browse files
committed
fix(slack): fix duplicate action_id breaking Home pagination
Slack rejects views where two buttons share the same action_id. Split action_home_drafts_page into action_home_drafts_prev and action_home_drafts_next. Added error logging for views.publish failures.
1 parent 9647ae6 commit ec141b6

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

backend/api/routes/feedback.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,24 @@ async def slack_interactions(
114114
logger.error("manual_post_modal_open_error", error=res.json())
115115
return Response(status_code=200)
116116

117-
if action_id == "action_home_drafts_page":
117+
if action_id in ("action_home_drafts_prev", "action_home_drafts_next"):
118118
page_offset = int(action_value) if action_value.isdigit() else 0
119119
repo = DraftRepository(session)
120120
drafts = await repo.get_recent_drafts(limit=10, offset=page_offset)
121121
home_view = build_app_home(drafts=drafts, offset=page_offset)
122122
async with httpx.AsyncClient() as client:
123-
await client.post(
123+
res = await client.post(
124124
"https://slack.com/api/views.publish",
125125
headers=headers,
126126
json={"user_id": user_id, "view": home_view},
127127
)
128+
if not res.json().get("ok"):
129+
logger.error(
130+
"home_pagination_publish_error",
131+
error=res.json(),
132+
user_id=user_id,
133+
page_offset=page_offset,
134+
)
128135
return Response(status_code=200)
129136

130137
if action_id == "action_open_generation_modal":

slack_app/utils/block_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def build_app_home(
528528
"emoji": True,
529529
},
530530
"value": str(offset - page_size),
531-
"action_id": "action_home_drafts_page",
531+
"action_id": "action_home_drafts_prev",
532532
}
533533
)
534534
if len(drafts) == page_size:
@@ -541,7 +541,7 @@ def build_app_home(
541541
"emoji": True,
542542
},
543543
"value": str(offset + page_size),
544-
"action_id": "action_home_drafts_page",
544+
"action_id": "action_home_drafts_next",
545545
}
546546
)
547547
if pagination_elements:

0 commit comments

Comments
 (0)