cli/cli · error

failed to render markdown: %w

Error message

failed to render markdown: %w

What it means

Error "failed to render markdown: %w" thrown in cli/cli.

Source

Thrown at pkg/cmd/agent-task/shared/log.go:318

	// markdown document. So, we must add the leading newline.
	formatFunc := func(s string) string {
		return fmt.Sprintf("\n%s\n\n", s)
	}

	return renderMarkdownWithFormat(md, w, io, formatFunc)
}

// renderMarkdownWithFormat renders the given markdown string to the given writer.
// If a formatFunc is provided, the md string is ran through it before
// rendering. This can be used to add newlines before and after the content.
func renderMarkdownWithFormat(md string, w io.Writer, io *iostreams.IOStreams, formatFunc func(string) string) error {
	rendered, err := markdown.Render(md,
		markdown.WithTheme(io.TerminalTheme()),
		markdown.WithWrap(io.TerminalWidth()),
	)

	if err != nil {
		return fmt.Errorf("failed to render markdown: %w", err)
	}

	rendered = strings.TrimSpace(rendered)
	if formatFunc != nil {
		rendered = formatFunc(rendered)
	}

	fmt.Fprint(w, rendered)

	return nil
}

// stripDiffFormat implements a primitive conversion from a diff string to a
// plain text representation by removing diff-specific formatting.
func stripDiffFormat(diff string) string {
	lines := strings.Split(diff, "\n")

	// Find where the hunk header ends.

View on GitHub (pinned to 0eeec0b92e)

Solutions

  1. This indicates an internal rendering failure; retry the command, and if it persists upgrade gh or report the issue.

When it happens

Trigger: Thrown at pkg/cmd/agent-task/shared/log.go:318 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15). Data as JSON: /api/errors/4bbb4483ed3b5254. Report an issue: GitHub.