{"record":{"id":"c01348c863a6b530","repo":"JanDeDobbeleer/oh-my-posh","slug":"failed-to-parse-config-w","errorCode":null,"errorMessage":"failed to parse config: %w","messagePattern":"failed to parse config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/wasm/main.go","lineNumber":110,"sourceCode":"\tconfigText := jsString(args[0])\n\tformat := jsString(args[1])\n\tdataJSON := jsString(args[2])\n\toptions := args[3]\n\n\t// An empty config means the built-in default, the same as it does for the CLI: config.Load\n\t// with no path returns config.Default(). Parsing \"\" instead would produce an empty Config and\n\t// render nothing, so a caller that wants to see what oh-my-posh looks like out of the box -\n\t// the website's own homepage does - has no other way to ask for it.\n\tvar cfg *config.Config\n\n\tvar err error\n\n\tif strings.TrimSpace(configText) == \"\" {\n\t\tcfg = config.Default(nil)\n\t} else {\n\t\tcfg, err = config.ParseBytes(format, []byte(configText))\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to parse config: %w\", err)\n\t\t}\n\t}\n\n\tvar data *config.Data\n\n\tif dataJSON != \"\" {\n\t\tdata, err = config.ParseData([]byte(dataJSON))\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to parse data: %w\", err)\n\t\t}\n\t}\n\n\t// applyData plays the same role here as the CLI image command's own\n\t// --data closure (cli/config_export_image.go, applyDataFile): it runs\n\t// against render.Config's freshly built flags before env.Init.\n\tapplyData := func(flags *runtime.Flags) error {\n\t\t// DataOnly makes the recorded data the only source a segment may\n\t\t// render from (see runtime.Flags.DataOnly's own doc comment). The","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/wasm/main.go#L92-L128","documentation":"renderSVG parses the provided config text with config.ParseBytes(format, data), the memory-only parser for TOML/JSON/YAML configs. This error wraps the parser's failure — the wrapped message identifies whether the format was unsupported, the syntax invalid, or a schema violation occurred. Because this is the WASM path, unlike the CLI it cannot load the config from a file, so the config text itself must be complete and valid (no `extends` from disk).","triggerScenarios":"Passing a non-empty configText whose syntax is invalid for the declared format (bad YAML/JSON/TOML), passing an unsupported format string, or a config whose fields fail config schema validation (e.g. extends pointing to a file, invalid segment types).","commonSituations":"Pasting a CLI theme that uses `extends: ../base.omp.toml` (resolvable on disk by the CLI but not in-memory in WASM), typos in config keys, format string mismatch (\"yml\" vs \"yaml\"), or JS template literals mangling the config text.","solutions":["Read the wrapped inner error (%w) — it names the exact parse/validation problem and line","Validate the same config with the CLI (`oh-my-posh config pretty` or rendering locally) to isolate syntax errors","Ensure the format argument matches the config text (\"yaml\", \"json\", or \"toml\")","Inline any `extends` references — the WASM parser cannot read files or URLs","Validate the config against website/static/schema.json"],"exampleFix":"// before\nconst cfg = 'extends: \"../base.omp.toml\"';\nomp.render(cfg, \"yaml\", \"\", {});  // failed to parse config\n// after: inline the full config text\nconst cfg = fs.readFileSync(\"base.omp.toml\", \"utf8\");\nomp.render(cfg, \"yaml\", \"\", {});","handlingStrategy":"try-catch","validationCode":"const formats = [\"yaml\", \"json\", \"toml\"];\nif (!formats.includes(format)) throw new Error(`unsupported format: ${format}`);\nif (configText.includes(\"extends:\")) console.warn(\"extends cannot be resolved in WASM — inline it\");","typeGuard":null,"tryCatchPattern":"try {\n  const { svg } = omp.render(configText, format, dataJSON, options);\n} catch (e) {\n  // e.error contains \"failed to parse config: <inner>\" — surface the inner message to the user\n}","preventionTips":["Validate configs with the CLI or website/static/schema.json before loading into WASM","Match the format argument to the actual config syntax","Inline any `extends` references — the WASM parser is memory-only","Quote config text carefully in JS template literals to avoid mangling syntax"],"tags":["go","wasm","config-parsing","yaml","toml","json"],"backgroundTag":"config-parse-failed","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}