{"record":{"id":"4444df117d7eb7a6","repo":"cli/cli","slug":"failed-to-create-discussion-w","errorCode":null,"errorMessage":"failed to create discussion: %w","messagePattern":"failed to create discussion: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/discussion/create/create.go","lineNumber":193,"sourceCode":"\t}\n\n\tinput := client.CreateDiscussionInput{\n\t\tCategoryID: category.ID,\n\t\tTitle:      opts.Title,\n\t\tBody:       opts.Body,\n\t\tLabelIDs:   labelIDs,\n\t}\n\n\topts.IO.StartProgressIndicator()\n\tdiscussion, err := c.Create(repo, input)\n\topts.IO.StopProgressIndicator()\n\tif err != nil {\n\t\tif discussion != nil {\n\t\t\tfmt.Fprintln(opts.IO.Out, discussion.URL)\n\t\t\tfmt.Fprintln(opts.IO.ErrOut, err.Error())\n\t\t\treturn cmdutil.SilentError\n\t\t}\n\t\treturn fmt.Errorf(\"failed to create discussion: %w\", err)\n\t}\n\n\tfmt.Fprintln(opts.IO.Out, discussion.URL)\n\n\treturn nil\n}\n","sourceCodeStart":175,"sourceCodeEnd":200,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/discussion/create/create.go#L175-L200","documentation":"A wrapper around discussionClient.Create failures that are total (the returned discussion is nil). Note the special case in the same block: if Create returns a non-nil discussion, the URL is printed to stdout, the raw error to stderr, and SilentError is returned instead - so this message only appears when nothing was created.","triggerScenarios":"gh discussion create where the createDiscussion mutation itself fails: repository discussions disabled (see 744), invalid category ID, permission denied, network/GraphQL errors. Label-only failures take the partial-success branch and never produce this message.","commonSituations":"Expired or scoped-down tokens; category resolved from stale cache; GitHub API incidents; discussions disabled on target repo.","solutions":["Read the wrapped cause after the colon - it carries the real reason (e.g. 'repository has discussions disabled')","Check auth: gh auth status","Verify the category slug exists: gh api repos/OWNER/REPO/discussions/categories or re-run letting the CLI pick it","If the discussion URL was printed to stdout, creation actually succeeded with partial failures - do not retry blindly (duplicate discussions)"],"exampleFix":"# before\ngh discussion create --title X --body Y --category nosuch  # failed to create discussion: ...\n\n# after\ngh discussion create --title X --body Y   # category picked interactively/validated","handlingStrategy":"try-catch","validationCode":"// pre-flight the two common total-failure causes\n// 1) gh repo view -R owner/repo --json hasDiscussions  -> must be true\n// 2) resolve category to a real slug before building input","typeGuard":null,"tryCatchPattern":"discussion, err := c.Create(repo, input)\nif err != nil {\n    if discussion != nil {\n        // URL already on stdout; log label failure, treat as success\n        return nil\n    }\n    return fmt.Errorf(\"creating discussion: %w\", err) // inspect wrapped cause\n}","preventionTips":["Unwrap the %w cause - the actionable reason is inside","Watch stdout: a printed URL means creation succeeded (no retry -> avoids duplicates)","Pre-check auth and category before creating in automation"],"tags":["discussions","create","wrapper","graphql"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}