cli/cli · info
Discarding...
Error message
Discarding...
What it means
This is not a failure but a cancellation signal: in the interactive comment-create flow, ConfirmSubmitSurvey() returned false (user answered 'no' to submit), so Commentable.Submit aborts with errors.New("Discarding..."). Callers typically detect this string or the user-cancel path to exit quietly.
Source
Thrown at pkg/cmd/pr/shared/commentable.go:179
var err error
if opts.Interactive {
body, err = opts.InteractiveEditSurvey("")
} else {
body, err = opts.EditSurvey("")
}
if err != nil {
return err
}
opts.Body = body
}
if opts.Interactive {
cont, err := opts.ConfirmSubmitSurvey()
if err != nil {
return err
}
if !cont {
return errors.New("Discarding...")
}
}
httpClient, err := opts.HttpClient()
if err != nil {
return err
}
apiClient := api.NewClientFromHTTP(httpClient)
params := api.CommentCreateInput{Body: opts.Body, SubjectId: commentable.Identifier()}
url, err := api.CommentCreate(apiClient, opts.Host, params)
if err != nil {
return err
}
if !opts.Quiet {
fmt.Fprintln(opts.IO.Out, url)
}View on GitHub (pinned to 0eeec0b92e)
Solutions
- If the comment should be posted, answer yes at the confirmation (or run non-interactively with --body)
- In wrappers, treat this message as a normal user cancellation: exit 0-style handling rather than retry
- Avoid interactive mode in automation: pass --body and --edit-last flags directly
Example fix
# before (interactive, user declines) gh pr comment 3 # -> error: Discarding... # after gh pr comment 3 --body "automated note"
Defensive patterns
Strategy: try-catch
Validate before calling
if [ ! -t 0 ]; then gh pr comment $N --body "$BODY"; else gh pr comment $N; fi
Try / catch
Treat errors whose message is exactly 'Discarding...' as user cancellation: log at info level and exit 0; all other errors propagate.
Prevention
- Use non-interactive --body in any automated context
- Wrappers should special-case this message as a clean cancel, not a failure
- Train users that declining the submit prompt discards the draft by design
When it happens
Trigger: `gh pr comment <n>` interactive flow where the user declines the final 'Submit?' confirmation; aborting with ESC/Ctrl-C at the confirm prompt.
Common situations: Users opening the comment flow to preview then backing out; scripts wrapping interactive gh sessions.
Related errors
- timed out while waiting for the codespace to start
- no comments found for current user
- unable to confirm: %w
- could not prompt: %w
- no git remotes
AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15).
Data as JSON: /api/errors/410b57dcf9193977.
Report an issue: GitHub.