{"record":{"id":"6b3b7b59027ab046","repo":"chenhg5/cc-connect","slug":"discord-no-buttons-provided","errorCode":null,"errorMessage":"discord: no buttons provided","messagePattern":"discord: no buttons provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/discord/discord.go","lineNumber":1180,"sourceCode":"\t\t\tcase 1:\n\t\t\t\tstyle = discordgo.DangerButton\n\t\t\tcase 2:\n\t\t\t\tstyle = discordgo.PrimaryButton\n\t\t\t}\n\t\t\tbuttons = append(buttons, discordgo.Button{\n\t\t\t\tLabel:    btn.Text,\n\t\t\t\tStyle:    style,\n\t\t\t\tCustomID: btn.Data,\n\t\t\t})\n\t\t}\n\t\tcomponents = append(components, discordgo.ActionsRow{Components: buttons})\n\t}\n\treturn components\n}\n\nfunc (p *Platform) SendWithButtons(ctx context.Context, rctx any, content string, buttons [][]core.ButtonOption) error {\n\tif len(buttons) == 0 {\n\t\treturn fmt.Errorf(\"discord: no buttons provided\")\n\t}\n\tcomponents := buildDiscordActionRows(buttons)\n\tif len(components) == 0 {\n\t\treturn fmt.Errorf(\"discord: no buttons provided\")\n\t}\n\n\tswitch rc := rctx.(type) {\n\tcase *interactionReplyCtx:\n\t\tif err := p.sendInteraction(rc, content); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err := p.session.FollowupMessageCreate(rc.interaction, true, &discordgo.WebhookParams{\n\t\t\tContent:    content,\n\t\t\tComponents: components,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"discord: send button followup: %w\", err)\n\t\t}","sourceCodeStart":1162,"sourceCodeEnd":1198,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/discord/discord.go#L1162-L1198","documentation":"SendWithButtons rejects the call up front when the buttons slice is empty, because Discord component messages require at least one ActionsRow/Button. The library treats an empty button payload as an invalid request rather than sending a button-less message. It fires before any Discord API call is made.","triggerScenarios":"Platform.SendWithButtons called with buttons == nil or buttons == [][]core.ButtonOption{} — typically a caller built the button grid conditionally and all conditions were false.","commonSituations":"Dynamic button construction that ends up empty; config produced no quick-action buttons; a caller passed an empty default value.","solutions":["Ensure callers pass at least one non-empty button row before calling SendWithButtons","Fall back to a plain Reply/Send when no buttons are needed instead of calling SendWithButtons","Validate the button grid in the caller and skip/return early","Log the call site to find where the empty grid originates"],"exampleFix":"// before\np.SendWithButtons(ctx, rctx, content, nil)\n// after\nif len(buttons) == 0 {\n    return p.Reply(ctx, rctx, content)\n}\nreturn p.SendWithButtons(ctx, rctx, content, buttons)","handlingStrategy":"validation","validationCode":"if len(buttons) == 0 || len(buttons[0]) == 0 {\n    return errors.New(\"at least one button row with a button is required\")\n}","typeGuard":null,"tryCatchPattern":"if err := p.SendWithButtons(ctx, rctx, content, buttons); err != nil {\n    if strings.Contains(err.Error(), \"no buttons provided\") {\n        return p.Reply(ctx, rctx, content)\n    }\n    return err\n}","preventionTips":["Build button grids conditionally and only call SendWithButtons when non-empty","Default to at least one action button in UI/config","Fall back to plain sends when no buttons apply","Unit-test button construction helpers for empty inputs"],"tags":["discord","validation","empty-argument","buttons"],"backgroundTag":"missing-required-argument","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}