{"record":{"id":"01e48794411797f1","repo":"wavetermdev/waveterm","slug":"unexpected-output-from-uname-s","errorCode":null,"errorMessage":"unexpected output from uname: %s","messagePattern":"unexpected output from uname: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/remote/connutil.go","lineNumber":71,"sourceCode":"\t\tarch = \"arm64\"\n\t}\n\treturn arch\n}\n\n// returns (os, arch, error)\n// guaranteed to return a supported platform\nfunc GetClientPlatform(ctx context.Context, shell genconn.ShellClient) (string, string, error) {\n\tblocklogger.Infof(ctx, \"[conndebug] running `uname -sm` to detect client platform\\n\")\n\tstdout, stderr, err := genconn.RunSimpleCommand(ctx, shell, genconn.CommandSpec{\n\t\tCmd: \"uname -sm\",\n\t})\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"error running uname -sm: %w, stderr: %s\", err, stderr)\n\t}\n\t// Parse and normalize output\n\tparts := strings.Fields(strings.ToLower(strings.TrimSpace(stdout)))\n\tif len(parts) != 2 {\n\t\treturn \"\", \"\", fmt.Errorf(\"unexpected output from uname: %s\", stdout)\n\t}\n\tos, arch := normalizeOs(parts[0]), normalizeArch(parts[1])\n\tif err := wavebase.ValidateWshSupportedArch(os, arch); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\treturn os, arch, nil\n}\n\nfunc GetClientPlatformFromOsArchStr(ctx context.Context, osArchStr string) (string, string, error) {\n\tparts := strings.Fields(strings.TrimSpace(osArchStr))\n\tif len(parts) != 2 {\n\t\treturn \"\", \"\", fmt.Errorf(\"unexpected output from uname: %s\", osArchStr)\n\t}\n\tos, arch := normalizeOs(parts[0]), normalizeArch(parts[1])\n\tif err := wavebase.ValidateWshSupportedArch(os, arch); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\treturn os, arch, nil","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/connutil.go#L53-L89","documentation":"After successfully running 'uname -sm', GetClientPlatform parses the output expecting exactly two whitespace-separated fields (OS and architecture). This error is thrown when the lowercased, trimmed output does not split into exactly 2 fields, so the platform cannot be normalized. Unlike the run-failure error, the command succeeded but returned unexpected text.","triggerScenarios":"The remote 'uname -sm' output has more or fewer than 2 fields: multi-line output from shell profile banners (motd echoed to stdout), shells wrapping commands, custom PS1/prompt leaking into captured stdout, or a shell printing an error line before uname output.","commonSituations":"Remote accounts with login banners or 'echo' statements in .bashrc/.profile; restricted shells that print warnings; wrapped/forked shells appending output; non-standard uname implementations printing extra columns.","solutions":["SSH into the remote host and run 'uname -sm' manually; remove any echo/banner output from shell startup files that pollutes stdout.","Check that the login shell for the remote user is a standard shell (bash/sh/zsh) without custom wrappers.","If uname output is genuinely non-standard, fall back to GetClientPlatformFromOsArchStr with a known os/arch string.","Inspect the string embedded in the error to see the actual polluted output and fix accordingly."],"exampleFix":"// before (remote ~/.bashrc)\necho \"Welcome to my server\"\n// after\n[ -z \"$PS1\" ] || echo \"Welcome to my server\"  # only for interactive shells","handlingStrategy":"fallback","validationCode":"if err := shell.Run(ctx, \"uname -sm\"); err != nil {\n    return err\n} // and inspect output has exactly 2 fields before calling GetClientPlatform indirectly","typeGuard":null,"tryCatchPattern":"os, arch, err := connutil.GetClientPlatform(ctx, shell)\nif err != nil && strings.Contains(err.Error(), \"unexpected output from uname\") {\n    os, arch, err = connutil.GetClientPlatformFromOsArchStr(ctx, manualOsArch)\n}","preventionTips":["Keep remote shell startup files (.bashrc/.profile) free of stdout output for non-interactive sessions.","Gate any echo/banner statements behind a [ -t 0 ] or $PS1 interactive check.","Use standard login shells (bash/sh/zsh) without wrappers for the connection user.","Cache a known-good os/arch string and use GetClientPlatformFromOsArchStr as a fallback."],"tags":["go","ssh","parsing","platform-detection"],"backgroundTag":"unexpected-command-output","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}