{"record":{"id":"70de2317323b9b70","repo":"wavetermdev/waveterm","slug":"unexpected-version-format-s","errorCode":null,"errorMessage":"unexpected version format: %s","messagePattern":"unexpected version format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/remote/conncontroller/conncontroller.go","lineNumber":322,"sourceCode":"\t\tif monitor != nil {\n\t\t\tupdateCallback = monitor.UpdateLastActivityTime\n\t\t}\n\t\twshutil.RunWshRpcOverListener(listener, updateCallback)\n\t}()\n\treturn nil\n}\n\n// expects the output of `wsh version` which looks like `wsh v0.10.4` or \"not-installed [os] [arch]\"\n// returns (up-to-date, semver, osArchStr, error)\n// if not up to date, or error, version might be \"\"\nfunc IsWshVersionUpToDate(logCtx context.Context, wshVersionLine string) (bool, string, string, error) {\n\twshVersionLine = strings.TrimSpace(wshVersionLine)\n\tif strings.HasPrefix(wshVersionLine, \"not-installed\") {\n\t\treturn false, \"not-installed\", strings.TrimSpace(strings.TrimPrefix(wshVersionLine, \"not-installed\")), nil\n\t}\n\tparts := strings.Fields(wshVersionLine)\n\tif len(parts) != 2 {\n\t\treturn false, \"\", \"\", fmt.Errorf(\"unexpected version format: %s\", wshVersionLine)\n\t}\n\tclientVersion := parts[1]\n\texpectedVersion := fmt.Sprintf(\"v%s\", wavebase.WaveVersion)\n\tif semver.Compare(clientVersion, expectedVersion) < 0 {\n\t\treturn false, clientVersion, \"\", nil\n\t}\n\treturn true, clientVersion, \"\", nil\n}\n\n// for testing only -- trying to determine the env difference when attaching or not attaching a pty to an ssh session\nfunc (conn *SSHConn) GetEnvironmentMaps(ctx context.Context) (map[string]string, map[string]string, error) {\n\tclient := conn.GetClient()\n\tif client == nil {\n\t\treturn nil, nil, fmt.Errorf(\"ssh client is not connected\")\n\t}\n\n\tnoPtyEnv, err := conn.getEnvironmentNoPty(ctx, client)\n\tif err != nil {","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/conncontroller/conncontroller.go#L304-L340","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reinstall the official matching wsh version on the remote (waveterm re-runs conn.UpdateWsh) to restore the expected output format","Clean the remote shell profile so no extra output is printed for non-interactive commands","Verify which wsh is resolved on the remote (which wsh) and remove conflicting binaries"],"exampleFix":"// before (.bashrc on remote)\necho \"Welcome!\"   // pollutes wsh --version output\n// after\n[ -t 0 ] && echo \"Welcome!\"   // only for interactive shells","handlingStrategy":"validation","validationCode":"out := runRemote(\"wsh --version\")\nlines := nonEmptyLines(out)\nif len(lines) != 1 || len(strings.Fields(lines[0])) != 2 {\n    return fmt.Errorf(\"remote wsh output malformed: %q\", out)\n}","typeGuard":null,"tryCatchPattern":"ok, ver, _, err := conn.IsWshVersionUpToDate(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected version format\") {\n        // reinstall/update wsh on remote\n        conn.ConnUpdateWshCommand(ctx)\n    }\n}","preventionTips":["Silence profile/motd output for non-interactive shells on remotes","Ensure 'wsh' in PATH is the official binary, not a wrapper","Reinstall wsh when waveterm version changes"],"tags":["versioning","wsh","parsing","ssh"],"backgroundTag":"unexpected-version-format","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}