Skip to content

Commit bdc8b35

Browse files
author
Codex
committed
Fix Slack edit modal invalid_arguments handling
1 parent aa269f2 commit bdc8b35

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

slack.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838

3939
actionUncertaintySelect = "uncertainty_select"
4040
actionUncertaintyOther = "uncertainty_other"
41+
noCategoryChangeValue = "__NO_CHANGE__"
4142

4243
actionRetroApply = "retro_apply"
4344
actionRetroDismiss = "retro_dismiss"
@@ -123,7 +124,7 @@ func handleMemberJoined(api *slack.Client, cfg Config, ev *slackevents.MemberJoi
123124
teamName = "the team"
124125
}
125126

126-
intro := fmt.Sprintf("Welcome to %s! I'm ReportBot — I help track work items and generate weekly reports.\n\n"+
127+
intro := fmt.Sprintf("Welcome to %s! I'm ReportAgent — I help track work items and generate weekly reports.\n\n"+
127128
"Here's how to get started:\n"+
128129
"• `/report <description> (status)` — Report a work item (e.g. `/report Fix login bug (done)`)\n"+
129130
"• `/list` — View this week's items\n"+
@@ -880,7 +881,7 @@ func handleViewSubmission(api *slack.Client, db *sql.DB, cfg Config, cb slack.In
880881
if catBlock, ok := values[editBlockCategory]; ok {
881882
if catAction, ok2 := catBlock[editActionCategory]; ok2 {
882883
newCategoryID := strings.TrimSpace(catAction.SelectedOption.Value)
883-
if newCategoryID != "" && newCategoryID != item.Category {
884+
if newCategoryID != "" && newCategoryID != noCategoryChangeValue && newCategoryID != item.Category {
884885
recordCategoryCorrection(db, cfg, item, newCategoryID, userID)
885886
if err := UpdateWorkItemCategory(db, itemID, newCategoryID); err != nil {
886887
log.Printf("edit modal category update error id=%d: %v", itemID, err)
@@ -980,8 +981,13 @@ func openEditModal(api *slack.Client, db *sql.DB, cfg Config, triggerID, channel
980981
var categoryBlock slack.Block
981982
sectionOpts := loadSectionOptionsForModal(cfg)
982983
if len(sectionOpts) > 0 {
984+
// Slack static_select supports up to 100 options.
985+
if len(sectionOpts) > 99 {
986+
log.Printf("openEditModal truncating category options from %d to 99 due to Slack limit", len(sectionOpts))
987+
sectionOpts = sectionOpts[:99]
988+
}
983989
noChangeOpt := slack.NewOptionBlockObject(
984-
"",
990+
noCategoryChangeValue,
985991
slack.NewTextBlockObject(slack.PlainTextType, "(no change)", false, false),
986992
nil,
987993
)
@@ -1049,6 +1055,9 @@ func openEditModal(api *slack.Client, db *sql.DB, cfg Config, triggerID, channel
10491055
Blocks: slack.Blocks{BlockSet: blocks},
10501056
}
10511057
if _, err := api.OpenView(triggerID, view); err != nil {
1058+
if apiErr, ok := err.(*slack.SlackErrorResponse); ok {
1059+
log.Printf("openEditModal slack error err=%s messages=%v", apiErr.Err, apiErr.ResponseMetadata.Messages)
1060+
}
10521061
postEphemeralTo(api, channelID, userID, fmt.Sprintf("Unable to open edit dialog: %v", err))
10531062
}
10541063
}

0 commit comments

Comments
 (0)