{"record":{"id":"410b57dcf9193977","repo":"cli/cli","slug":"discarding","errorCode":null,"errorMessage":"Discarding...","messagePattern":"Discarding\\.\\.\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/cmd/pr/shared/commentable.go","lineNumber":179,"sourceCode":"\t\tvar err error\n\t\tif opts.Interactive {\n\t\t\tbody, err = opts.InteractiveEditSurvey(\"\")\n\t\t} else {\n\t\t\tbody, err = opts.EditSurvey(\"\")\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\topts.Body = body\n\t}\n\n\tif opts.Interactive {\n\t\tcont, err := opts.ConfirmSubmitSurvey()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !cont {\n\t\t\treturn errors.New(\"Discarding...\")\n\t\t}\n\t}\n\n\thttpClient, err := opts.HttpClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tapiClient := api.NewClientFromHTTP(httpClient)\n\tparams := api.CommentCreateInput{Body: opts.Body, SubjectId: commentable.Identifier()}\n\turl, err := api.CommentCreate(apiClient, opts.Host, params)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !opts.Quiet {\n\t\tfmt.Fprintln(opts.IO.Out, url)\n\t}","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/pr/shared/commentable.go#L161-L197","documentation":"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.","triggerScenarios":"`gh pr comment <n>` interactive flow where the user declines the final 'Submit?' confirmation; aborting with ESC/Ctrl-C at the confirm prompt.","commonSituations":"Users opening the comment flow to preview then backing out; scripts wrapping interactive gh sessions.","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"],"exampleFix":"# before (interactive, user declines)\ngh pr comment 3   # -> error: Discarding...\n# after\ngh pr comment 3 --body \"automated note\"","handlingStrategy":"try-catch","validationCode":"if [ ! -t 0 ]; then gh pr comment $N --body \"$BODY\"; else gh pr comment $N; fi","typeGuard":null,"tryCatchPattern":"Treat errors whose message is exactly 'Discarding...' as user cancellation: log at info level and exit 0; all other errors propagate.","preventionTips":["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"],"tags":["pull-request","comment","cancellation","interactive"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}