wavetermdev/waveterm · warning

unexpected version format: %s

Error message

unexpected version format: %s

What it means

IsWshVersionUpToDate parses the output of the remote 'wsh --version' probe, expecting exactly two whitespace-separated fields (e.g. 'wsh version v0.10.3'). 'not-installed' is handled specially; anything else that does not split into exactly 2 fields yields 'unexpected version format'.

Source

Thrown at pkg/remote/conncontroller/conncontroller.go:322

		if monitor != nil {
			updateCallback = monitor.UpdateLastActivityTime
		}
		wshutil.RunWshRpcOverListener(listener, updateCallback)
	}()
	return nil
}

// expects the output of `wsh version` which looks like `wsh v0.10.4` or "not-installed [os] [arch]"
// returns (up-to-date, semver, osArchStr, error)
// if not up to date, or error, version might be ""
func IsWshVersionUpToDate(logCtx context.Context, wshVersionLine string) (bool, string, string, error) {
	wshVersionLine = strings.TrimSpace(wshVersionLine)
	if strings.HasPrefix(wshVersionLine, "not-installed") {
		return false, "not-installed", strings.TrimSpace(strings.TrimPrefix(wshVersionLine, "not-installed")), nil
	}
	parts := strings.Fields(wshVersionLine)
	if len(parts) != 2 {
		return false, "", "", fmt.Errorf("unexpected version format: %s", wshVersionLine)
	}
	clientVersion := parts[1]
	expectedVersion := fmt.Sprintf("v%s", wavebase.WaveVersion)
	if semver.Compare(clientVersion, expectedVersion) < 0 {
		return false, clientVersion, "", nil
	}
	return true, clientVersion, "", nil
}

// for testing only -- trying to determine the env difference when attaching or not attaching a pty to an ssh session
func (conn *SSHConn) GetEnvironmentMaps(ctx context.Context) (map[string]string, map[string]string, error) {
	client := conn.GetClient()
	if client == nil {
		return nil, nil, fmt.Errorf("ssh client is not connected")
	}

	noPtyEnv, err := conn.getEnvironmentNoPty(ctx, client)
	if err != nil {

View on GitHub (pinned to a4447c1563)

Solutions

  1. Reinstall the official matching wsh version on the remote (waveterm re-runs conn.UpdateWsh) to restore the expected output format
  2. Clean the remote shell profile so no extra output is printed for non-interactive commands
  3. Verify which wsh is resolved on the remote (which wsh) and remove conflicting binaries

Example fix

// before (.bashrc on remote)
echo "Welcome!"   // pollutes wsh --version output
// after
[ -t 0 ] && echo "Welcome!"   // only for interactive shells
Defensive patterns

Strategy: validation

Validate before calling

out := runRemote("wsh --version")
lines := nonEmptyLines(out)
if len(lines) != 1 || len(strings.Fields(lines[0])) != 2 {
    return fmt.Errorf("remote wsh output malformed: %q", out)
}

Try / catch

ok, ver, _, err := conn.IsWshVersionUpToDate(ctx)
if err != nil {
    if strings.Contains(err.Error(), "unexpected version format") {
        // reinstall/update wsh on remote
        conn.ConnUpdateWshCommand(ctx)
    }
}

Prevention

When it happens

Trigger: The remote wsh version command prints output in an unrecognized layout — a different wsh build, wrapper scripts emitting extra lines, locale text, or a shell profile echoing banners before the version string.

Common situations: User has an old or custom wsh binary on the remote; login scripts (motd, echo statements in .bashrc) polluting command output; a PATH-resolved 'wsh' that is not the real wsh.

Related errors


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