JanDeDobbeleer/oh-my-posh · error

render expects 4 arguments (configText, format, dataJSON, op

Error message

render expects 4 arguments (configText, format, dataJSON, options), got %d

What it means

oh-my-posh's WASM module exposes a render() JS binding that renders a prompt config to SVG in the browser. The underlying renderSVG function requires exactly the arguments configText, format, dataJSON, and options. This error is thrown when fewer than 4 arguments are passed to the JS call, and it reports how many were actually received.

Source

Thrown at src/wasm/main.go:89

	doc, err := renderSVG(args)
	if err != nil {
		return map[string]any{"error": err.Error()}
	}

	return map[string]any{"svg": doc}
}

// renderSVG does the actual work: parse the config and optional data from
// memory, render them, and encode the result - all through config's memory
// parsers and the render package, never through config.Load or anything
// else that would touch a file or the network (config.ParseBytes/
// config.ParseData are exactly the memory-only counterparts to config.Load's
// file-and-URL-reading Parse; see their own doc comments for why a config
// parsed this way can never pull in a remote "extends").
func renderSVG(args []js.Value) (string, error) {
	if len(args) < 4 {
		return "", fmt.Errorf("render expects 4 arguments (configText, format, dataJSON, options), got %d", len(args))
	}

	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 {

View on GitHub (pinned to 0976794618)

Solutions

  1. Pass all 4 positional arguments: render(configText, format, dataJSON, options)
  2. Pass an empty string for configText to get the default config, and "{}"/empty for dataJSON if no data
  3. Pass a valid options object (even an empty JS object) as the 4th argument
  4. Check the current wasm JS glue (render.d.ts / generated bindings) for the exact signature

Example fix

// before
const out = omp.render(cfgText, "yaml", JSON.stringify(data));
// after
const out = omp.render(cfgText, "yaml", JSON.stringify(data), {});
Defensive patterns

Strategy: validation

Validate before calling

if (arguments.length < 4) {
  throw new Error("render requires (configText, format, dataJSON, options)");
}
omp.render(configText, format, dataJSON, options ?? {});

Try / catch

try {
  const result = omp.render(cfg, fmt, data, opts);
} catch (e) {
  if (String(e).includes("render expects 4 arguments")) {
    // fix the call site signature
  }
}

Prevention

When it happens

Trigger: Calling wasmBindgen-exported render/renderJS with 0-3 arguments — e.g. render(configText, format, dataJSON) without options, or render(config) with a single object instead of positional args.

Common situations: Website/integration code calling the WASM renderer after an API change, wrapping the call and dropping trailing optional-looking arguments, or older documentation showing a shorter signature.

Related errors


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