{"record":{"id":"4bbb4483ed3b5254","repo":"cli/cli","slug":"failed-to-render-markdown-w","errorCode":null,"errorMessage":"failed to render markdown: %w","messagePattern":"failed to render markdown: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/agent-task/shared/log.go","lineNumber":318,"sourceCode":"\t// markdown document. So, we must add the leading newline.\n\tformatFunc := func(s string) string {\n\t\treturn fmt.Sprintf(\"\\n%s\\n\\n\", s)\n\t}\n\n\treturn renderMarkdownWithFormat(md, w, io, formatFunc)\n}\n\n// renderMarkdownWithFormat renders the given markdown string to the given writer.\n// If a formatFunc is provided, the md string is ran through it before\n// rendering. This can be used to add newlines before and after the content.\nfunc renderMarkdownWithFormat(md string, w io.Writer, io *iostreams.IOStreams, formatFunc func(string) string) error {\n\trendered, err := markdown.Render(md,\n\t\tmarkdown.WithTheme(io.TerminalTheme()),\n\t\tmarkdown.WithWrap(io.TerminalWidth()),\n\t)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to render markdown: %w\", err)\n\t}\n\n\trendered = strings.TrimSpace(rendered)\n\tif formatFunc != nil {\n\t\trendered = formatFunc(rendered)\n\t}\n\n\tfmt.Fprint(w, rendered)\n\n\treturn nil\n}\n\n// stripDiffFormat implements a primitive conversion from a diff string to a\n// plain text representation by removing diff-specific formatting.\nfunc stripDiffFormat(diff string) string {\n\tlines := strings.Split(diff, \"\\n\")\n\n\t// Find where the hunk header ends.","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/agent-task/shared/log.go#L300-L336","documentation":"Error \"failed to render markdown: %w\" thrown in cli/cli.","triggerScenarios":"Thrown at pkg/cmd/agent-task/shared/log.go:318 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["This indicates an internal rendering failure; retry the command, and if it persists upgrade gh or report the issue."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}