{"record":{"id":"32935708fad6cbd4","repo":"JanDeDobbeleer/oh-my-posh","slug":"failed-to-record-theme-s-w","errorCode":null,"errorMessage":"failed to record theme %s: %w","messagePattern":"failed to record theme (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/config_export_data.go","lineNumber":223,"sourceCode":"// exactly as the single-config path above does, then returns its sanitized env\n// and segment maps for merging. Each call gets its own fresh template cache\n// (resetTemplateCache=true, below, drives render.Config's own\n// template.ResetCache before template.Init) so one theme's Var/Maps never leak\n// into the next theme's render, the same isolation prompt/golden_test.go's\n// renderTheme relies on between themes.\nfunc recordThemeSanitized(themePath string) (env, segments map[string]json.RawMessage, err error) {\n\tcfg := config.Load(themePath)\n\tif cfg.Source == \"\" {\n\t\treturn nil, nil, fmt.Errorf(\"failed to parse theme %s\", themePath)\n\t}\n\n\t// --data seeds the writers with a fixture's own values before they render, so re-recording an\n\t// existing file keeps what it was curated with and only adds what the format has since gained.\n\t// Without it every theme would record whatever this machine happens to look like.\n\tif _, err := render.Config(cfg, 120, true, func(flags *runtime.Flags) error {\n\t\treturn applyDataFile(flags, func(string) bool { return false })\n\t}); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to record theme %s: %w\", themePath, err)\n\t}\n\n\tdoc, err := buildDataDocument(cfg)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to record theme %s: %w\", themePath, err)\n\t}\n\n\tsanitized, err := sanitizeDataDocument(doc, cfg)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to sanitize theme %s: %w\", themePath, err)\n\t}\n\n\tvar root map[string]json.RawMessage\n\tif err := json.Unmarshal(sanitized, &root); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to parse recorded theme %s: %w\", themePath, err)\n\t}\n\n\tif raw, ok := root[config.DataEnvKey]; ok {","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/config_export_data.go#L205-L241","documentation":"recordThemeSanitized renders a theme's segments against the real environment via render.Config (seeding writers from any --data file). If render.Config returns an error, it is wrapped as \"failed to record theme <path>: <reason>\". The cause is whatever went wrong during rendering — a failing segment, environment query error, or flag application problem.","triggerScenarios":"Running `config export data --themes --sanitize` when render.Config fails for a theme — e.g. a segment errors hard during render, the seeded --data fixture is incompatible with the theme, or the runtime environment returns an error the engine surfaces.","commonSituations":"A theme uses a segment that crashes/errors on this machine (missing tool, bad credential); a stale --data fixture missing newly required keys; shell/terminal environment mis-detected during batch theme recording.","solutions":["Inspect the wrapped cause to find which segment or step failed","Rerun without --data (or with a freshly recorded fixture) to rule out stale seed data","Test the failing theme alone via `oh-my-posh config export data --config <theme>` to reproduce and narrow the cause","Update oh-my-posh; if a bundled theme fails, report it with the wrapped error"],"exampleFix":"// before\noh-my-posh config export data --sanitize --themes ../themes --data old.data.json\n\n// after (fresh recording, no seed)\noh-my-posh config export data --sanitize --themes ../themes","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"env, segments, err := recordThemeSanitized(themePath)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to record theme\") {\n\t\t// inspect the wrapped render cause\n\t\tlog.Printf(\"theme render failed: %v\", err)\n\t\treturn err\n\t}\n\treturn err\n}","preventionTips":["Record one theme with --config first to verify it renders on your machine","Regenerate --data fixtures when the oh-my-posh version changes","Ensure external tools segments rely on (git, etc.) are installed and authenticated","Set POSH_SHELL/environment consistently when recording in CI"],"tags":["render","themes","export","segments"],"backgroundTag":"render-failed","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}