JanDeDobbeleer/oh-my-posh · error

unsupported data file extension: %s

Error message

unsupported data file extension: %s

What it means

Thrown when decodeDataRoot receives a file extension it does not recognize. Data files are only supported for JSON/JSONC (.json/.jsonc), YAML (.yaml/.yml) and TOML (.toml/.tml); anything else is rejected before any parsing is attempted.

Source

Thrown at src/config/data.go:206

			return nil, fmt.Errorf("failed to parse data file: %w", err)
		}

		root = normalized
	case TOML, TML:
		var generic map[string]any

		if err := toml.Unmarshal(raw, &generic); err != nil {
			return nil, fmt.Errorf("failed to parse data file: %w", err)
		}

		normalized, err := normalize(generic)
		if err != nil {
			return nil, fmt.Errorf("failed to parse data file: %w", err)
		}

		root = normalized
	default:
		return nil, fmt.Errorf("unsupported data file extension: %s", ext)
	}

	return root, nil
}

// dataFromRoot builds a Data from a generically-decoded document root,
// shared by LoadData (any of its three formats) and ParseData (JSON only)
// once each has the same map[string]json.RawMessage shape in hand.
func dataFromRoot(root map[string]json.RawMessage) (*Data, error) {
	data := &Data{}

	if versionRaw, OK := root[DataVersionKey]; OK {
		if err := json.Unmarshal(versionRaw, &data.Version); err != nil {
			return nil, fmt.Errorf("failed to parse version in data file: %w", err)
		}
	}

	if env, OK := root[DataEnvKey]; OK {

View on GitHub (pinned to 0976794618)

Solutions

  1. Rename the file (or the configured path) to use a supported extension: .json, .jsonc, .yaml, .yml, .toml, or .tml
  2. Convert the file's content into one of the supported formats if it currently uses another syntax
  3. If the file has no extension, add the one matching its content format

Example fix

// before
load("scripts/mydata.env")
// after
load("scripts/mydata.json")
Defensive patterns

Strategy: validation

Validate before calling

supported := map[string]bool{"json":true,"jsonc":true,"yaml":true,"yml":true,"toml":true,"tml":true}
ext := strings.TrimPrefix(filepath.Ext(path), ".")
if !supported[strings.ToLower(ext)] {
	return fmt.Errorf("rename %s to use a supported extension", path)
}

Try / catch

data, err := config.LoadData(path)
if err != nil && strings.Contains(err.Error(), "unsupported data file extension") {
	// fall back to a known-good data file with a supported extension
}

Prevention

When it happens

Trigger: Calling LoadData with a path whose extension is not one of json, jsonc, yaml, yml, toml, tml - e.g. .ini, .conf, .properties, .txt, or a file with no extension at all.

Common situations: Pointing a data file setting at an environment export script (.sh, .ps1, .env); renaming a data file and losing the extension; Unix-style extensionless dotfiles; typos like .toml.bak that still end in .bak.

Related errors


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