{"record":{"id":"54ab343f2856e4ed","repo":"kovidgoyal/kitty","slug":"invalid-ssh-connection-data-need-at-least-binar","errorCode":null,"errorMessage":"invalid --ssh-connection-data: need at least binary and hostname","messagePattern":"invalid --ssh-connection-data: need at least binary and hostname","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/remote_file/ssh.go","lineNumber":31,"sourceCode":"// Must match kittens/remote_file/main.py is_ssh_kitten_sentinel\nconst is_ssh_kitten_sentinel = `!#*&$#($ssh-kitten)(##$`\n\ntype SSHConnectionData struct {\n\tBinary           string\n\tHostname         string\n\tPort             int\n\tIdentityFile     string\n\tIsSSHKitten      bool\n\tSSHKittenCmdline []string\n}\n\nfunc parse_conn_data(raw string) (*SSHConnectionData, error) {\n\tvar items []any\n\tif err := json.Unmarshal([]byte(raw), &items); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid --ssh-connection-data: %w\", err)\n\t}\n\tif len(items) < 2 {\n\t\treturn nil, fmt.Errorf(\"invalid --ssh-connection-data: need at least binary and hostname\")\n\t}\n\tfirst, _ := items[0].(string)\n\tans := &SSHConnectionData{}\n\tif first == is_ssh_kitten_sentinel {\n\t\t// Python: SSHConnectionData(sentinel, cli_data[-1], -1, identity_file=json.dumps(cli_data[1:]))\n\t\t// with the cmdline stripped of -t flags and its last two items.\n\t\tans.IsSSHKitten = true\n\t\tans.Hostname, _ = items[len(items)-1].(string)\n\t\tcmdline := make([]string, 0, len(items)-1)\n\t\tfor _, x := range items[1:] {\n\t\t\ts, _ := x.(string)\n\t\t\tif s != \"-t\" {\n\t\t\t\tcmdline = append(cmdline, s)\n\t\t\t}\n\t\t}\n\t\t// Python: sk_cmdline[:-2] always removes last 2, or returns empty if fewer items\n\t\tif len(cmdline) >= 2 {\n\t\t\tcmdline = cmdline[:len(cmdline)-2]","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/remote_file/ssh.go#L13-L49","documentation":"parse_conn_data requires the JSON array in --ssh-connection-data to contain at least two items: the ssh binary and the hostname. With fewer than 2 elements it rejects the input with this message.","triggerScenarios":"Passing a JSON array like [\"/usr/bin/ssh\"] or [] as --ssh-connection-data.","commonSituations":"Truncation of the argument by shell splitting or quoting bugs, or test fixtures that only include the binary.","solutions":["Include at least [ssh_binary, hostname] in the array","Check the argument was not truncated by quoting/word-splitting","Update test fixtures to include both elements"],"exampleFix":"// before\n[\"/usr/bin/ssh\"]\n// after\n[\"/usr/bin/ssh\",\"user@host\"]","handlingStrategy":"validation","validationCode":"var items []any\nif json.Unmarshal([]byte(raw), &items) == nil && len(items) >= 2 { /* ok */ }","typeGuard":"func hasBinaryAndHost(raw string) bool { var v []any; return json.Unmarshal([]byte(raw), &v) == nil && len(v) >= 2 }","tryCatchPattern":null,"preventionTips":["Ensure the array contains binary and hostname","Validate fixture data in tests"],"tags":["json","validation","cli-args","ssh"],"backgroundTag":"invalid-json-input","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}