JanDeDobbeleer/oh-my-posh · error

failed to parse config: %w

Error message

failed to parse config: %w

What it means

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).

Source

Thrown at src/wasm/main.go:110

	configText := jsString(args[0])
	format := jsString(args[1])
	dataJSON := jsString(args[2])
	options := args[3]

	// An empty config means the built-in default, the same as it does for the CLI: config.Load
	// with no path returns config.Default(). Parsing "" instead would produce an empty Config and
	// render nothing, so a caller that wants to see what oh-my-posh looks like out of the box -
	// the website's own homepage does - has no other way to ask for it.
	var cfg *config.Config

	var err error

	if strings.TrimSpace(configText) == "" {
		cfg = config.Default(nil)
	} else {
		cfg, err = config.ParseBytes(format, []byte(configText))
		if err != nil {
			return "", fmt.Errorf("failed to parse config: %w", err)
		}
	}

	var data *config.Data

	if dataJSON != "" {
		data, err = config.ParseData([]byte(dataJSON))
		if err != nil {
			return "", fmt.Errorf("failed to parse data: %w", err)
		}
	}

	// applyData plays the same role here as the CLI image command's own
	// --data closure (cli/config_export_image.go, applyDataFile): it runs
	// against render.Config's freshly built flags before env.Init.
	applyData := func(flags *runtime.Flags) error {
		// DataOnly makes the recorded data the only source a segment may
		// render from (see runtime.Flags.DataOnly's own doc comment). The

View on GitHub (pinned to 0976794618)

Solutions

  1. Read the wrapped inner error (%w) — it names the exact parse/validation problem and line
  2. Validate the same config with the CLI (`oh-my-posh config pretty` or rendering locally) to isolate syntax errors
  3. Ensure the format argument matches the config text ("yaml", "json", or "toml")
  4. Inline any `extends` references — the WASM parser cannot read files or URLs
  5. Validate the config against website/static/schema.json

Example fix

// before
const cfg = 'extends: "../base.omp.toml"';
omp.render(cfg, "yaml", "", {});  // failed to parse config
// after: inline the full config text
const cfg = fs.readFileSync("base.omp.toml", "utf8");
omp.render(cfg, "yaml", "", {});
Defensive patterns

Strategy: try-catch

Validate before calling

const formats = ["yaml", "json", "toml"];
if (!formats.includes(format)) throw new Error(`unsupported format: ${format}`);
if (configText.includes("extends:")) console.warn("extends cannot be resolved in WASM — inline it");

Try / catch

try {
  const { svg } = omp.render(configText, format, dataJSON, options);
} catch (e) {
  // e.error contains "failed to parse config: <inner>" — surface the inner message to the user
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/c01348c863a6b530. Report an issue: GitHub.