wavetermdev/waveterm · error

formatting version info: %v

Error message

formatting version info: %v

What it means

In `wsh version --output json` mode, the collected info map is serialized with json.MarshalIndent. MarshalIndent rarely fails for this plain map[string]string, so this wrapper indicates an unexpected serialization bug or malformed data placed into the info map.

Source

Thrown at cmd/wsh/cmd/wshcmd-version.go:65

	}

	updateChannel, err := wshclient.GetUpdateChannelCommand(RpcClient, &wshrpc.RpcOpts{Timeout: 2000, Route: wshutil.ElectronRoute})
	if err != nil {
		return err
	}

	if versionJSON {
		info := map[string]interface{}{
			"version":       resp.Version,
			"clientid":      resp.ClientId,
			"buildtime":     resp.BuildTime,
			"configdir":     resp.ConfigDir,
			"datadir":       resp.DataDir,
			"updatechannel": updateChannel,
		}
		outBArr, err := json.MarshalIndent(info, "", "  ")
		if err != nil {
			return fmt.Errorf("formatting version info: %v", err)
		}
		WriteStdout("%s\n", string(outBArr))
		return nil
	}

	// Default verbose text output
	fmt.Printf("v%s (%s)\n", resp.Version, resp.BuildTime)
	fmt.Printf("clientid:  %s\n", resp.ClientId)
	fmt.Printf("configdir: %s\n", resp.ConfigDir)
	fmt.Printf("datadir:   %s\n", resp.DataDir)
	fmt.Printf("update-channel: %s\n", updateChannel)
	return nil
}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Retry with a stock build; if it persists, report it as a bug since this map should only contain strings.
  2. Audit the info map construction in wshcmd-version.go for non-serializable values added by recent changes.
  3. As a workaround use the default verbose text output (omit --output json).

Example fix

// before
outBArr, err := json.MarshalIndent(info, "", "  ")
if err != nil {
	return fmt.Errorf("formatting version info: %v", err)
}
// after
outBArr, err := json.MarshalIndent(info, "", "  ")
if err != nil {
	return fmt.Errorf("formatting version info: %v", err)
}
_ = outBArr // ensure info only contains string values when extending the map
Defensive patterns

Strategy: try-catch

Try / catch

outBArr, err := json.MarshalIndent(info, "", "  ")
if err != nil {
	// fall back to plain text output so the command still succeeds
	return printPlainTextVersion()
}

Prevention

When it happens

Trigger: json.MarshalIndent(info, "", " ") returning an error — practically only if a non-JSON-serializable value (e.g. a channel or func) is inserted into the info map.

Common situations: A code change adds a field to the info map that isn't a JSON-safe type; running a build with locally modified version info sources.

Understand the failure class

Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/2dcb38cffcc6413f. Report an issue: GitHub.