{"record":{"id":"5f7a2ba851033020","repo":"plandex-ai/plandex","slug":"failed-to-create-glamour-renderer-w","errorCode":null,"errorMessage":"failed to create glamour renderer: %w","messagePattern":"failed to create glamour renderer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/term/format.go","lineNumber":50,"sourceCode":"\tvar opts []glamour.TermRendererOption\n\n\t// Check for a GLAMOUR_STYLE env variable.\n\tif style, ok := os.LookupEnv(\"GLAMOUR_STYLE\"); ok && style != \"\" {\n\t\topts = append(opts, glamour.WithStandardStyle(style))\n\t} else {\n\t\t// Fallback to auto style detection.\n\t\topts = append(opts, glamour.WithAutoStyle())\n\t}\n\n\t// Always set word wrap and preserved newlines.\n\topts = append(opts,\n\t\tglamour.WithWordWrap(min(width, 80)),\n\t\tglamour.WithPreservedNewLines(),\n\t)\n\n\tr, err := glamour.NewTermRenderer(opts...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create glamour renderer: %w\", err)\n\t}\n\n\tcachedGlamourRenderer = r\n\tcachedGlamourRendererWidth = width\n\treturn r, nil\n}\n\nfunc GetMarkdown(input string) (string, error) {\n\tinputBytes := utils.RemoveFrontmatter([]byte(input))\n\n\tr, err := getGlamourRenderer()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tout, err := r.RenderBytes(inputBytes)\n\tif err != nil {\n\t\treturn \"\", err","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/term/format.go#L32-L68","documentation":"getGlamourRenderer builds a glamour.TermRenderer for terminal markdown rendering and wraps any construction failure. glamour.NewTermRenderer fails mainly when the style name is invalid or style assets can't be loaded. Because package init() calls this, a bad GLAMOUR_STYLE env var can break the package at startup.","triggerScenarios":"GLAMOUR_STYLE env var is set to an unknown style name (anything not dark/light/notty/ascii/dracula/etc. or a valid style JSON path), or the installed glamour version cannot load its style definitions.","commonSituations":"Developers set GLAMOUR_STYLE=drak (typo) or a custom style file path that doesn't exist; CI environments with a stale GLAMOUR_STYLE exported in shell profile; version upgrade changed valid style names.","solutions":["Check GLAMOUR_STYLE value; unset it or set it to a valid standard style (dark, light, notty, ascii)","If using a custom style JSON, verify the file path exists and is valid JSON","Run with GLAMOUR_STYLE unset to confirm auto-style works","Update glamour to a version whose style set matches the configured name"],"exampleFix":"// before\nexport GLAMOUR_STYLE=drak\n// after\nexport GLAMOUR_STYLE=dark  # or unset GLAMOUR_STYLE","handlingStrategy":"validation","validationCode":"if style := os.Getenv(\"GLAMOUR_STYLE\"); style != \"\" {\n    for _, valid := range []string{\"dark\",\"light\",\"notty\",\"ascii\",\"dracula\",\"nord\",\"tokyo-night\"} {\n        if style == valid { goto ok }\n    }\n    // unknown style: unset or fix GLAMOUR_STYLE before running\n}","typeGuard":null,"tryCatchPattern":"r, err := getGlamourRenderer()\nif err != nil {\n    // fallback: render plain text instead of failing\n    fmt.Println(input)\n    return nil\n}","preventionTips":["Only set GLAMOUR_STYLE to documented standard styles or a valid style JSON file","Sanitize shell profiles shared across machines for stale GLAMOUR_STYLE values","Pin glamour versions and verify style names after upgrades"],"tags":["go","glamour","markdown","terminal","env-var"],"backgroundTag":"invalid-style-name","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}