{"record":{"id":"3217ed55aa229321","repo":"JanDeDobbeleer/oh-my-posh","slug":"failed-to-sanitize-theme-s-w","errorCode":null,"errorMessage":"failed to sanitize theme %s: %w","messagePattern":"failed to sanitize theme (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/config_export_data.go","lineNumber":233,"sourceCode":"\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 {\n\t\tif err := json.Unmarshal(raw, &env); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"failed to parse env for theme %s: %w\", themePath, err)\n\t\t}\n\t}\n\n\tif raw, ok := root[config.DataSegmentsKey]; ok {\n\t\tif err := json.Unmarshal(raw, &segments); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"failed to parse segments for theme %s: %w\", themePath, err)\n\t\t}\n\t}","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/config_export_data.go#L215-L251","documentation":"Once a theme's document is built, recordThemeSanitized sanitizes it via sanitizeDataDocument (scrubbing identity fields). If sanitization fails, the theme is aborted with \"failed to sanitize theme <path>: <reason>\". The cause is internal to sanitizeDataDocument — typically it could not process the recorded document for this theme.","triggerScenarios":"Running `config export data --themes --sanitize` when sanitizeDataDocument errors on the theme's freshly recorded document — e.g. the document lacks an expected structure the sanitizer assumes, or a scrubber fails on this theme's segment data.","commonSituations":"A theme recording a segment shape the sanitizer does not expect (new segment type added without a sanitization rule); malformed recorded document from an upstream marshal glitch; custom or dev builds where sanitizer and record formats drifted.","solutions":["Check the wrapped cause to see which sanitization step failed","Update oh-my-posh — this usually indicates a mismatch between recording and sanitizing logic fixed upstream","Retry recording just that theme with --config + --sanitize to isolate it from the batch","If developing: add/fix the sanitizer rule for the segment named in the wrapped error"],"exampleFix":"// before (sanitizer unaware of new segment)\n// no case for \"newsegment\" in sanitizeDataDocument\n\n// after\n// add a scrub rule for the newsegment's identity-bearing keys","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"sanitized, err := sanitizeDataDocument(doc, cfg)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to sanitize theme\") {\n\t\tlog.Printf(\"sanitizer rejected theme output: %v\", err)\n\t\treturn err\n\t}\n\treturn err\n}","preventionTips":["Keep sanitizer rules in sync when adding new segments or identity-bearing fields","Update oh-my-posh before regenerating committed fixtures","Record the failing theme individually to isolate sanitizer vs recorder issues","Diff the freshly recorded document against a known-good fixture to spot unexpected shapes"],"tags":["sanitize","themes","export","privacy"],"backgroundTag":"sanitization-failed","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}