{"record":{"id":"622d5fe56ad272d6","repo":"kovidgoyal/kitty","slug":"unknown-option-arg-1","errorCode":null,"errorMessage":"unknown option -- {arg[1:]}","messagePattern":"unknown option -- (.+?)","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"kittens/ssh/utils.py","lineNumber":305,"sourceCode":"                        expecting_extra_val = matching_ex\n                        expecting_option_val = True\n                    continue\n            # could be a multi-character option\n            all_args = argument[1:]\n            for i, arg in enumerate(all_args):\n                arg = f'-{arg}'\n                if arg in boolean_ssh_args:\n                    ssh_args.append(arg)\n                    continue\n                if arg in other_ssh_args:\n                    ssh_args.append(arg)\n                    rest = all_args[i + 1 :]\n                    if rest:\n                        ssh_args.append(rest)\n                    else:\n                        expecting_option_val = True\n                    break\n                raise KeyError(f'unknown option -- {arg[1:]}')\n            continue\n        if expecting_option_val:\n            if expecting_extra_val:\n                found_extra_args.extend((expecting_extra_val, argument))\n                expecting_extra_val = ''\n            else:\n                ssh_args.append(argument)\n            expecting_option_val = False\n            continue\n        del ans[i + 1 :]\n        if allocate_tty and ans[i] != '-t':\n            ans.insert(i, '-t')\n        break\n    argv[:] = ans + server_args\n\n\ndef get_connection_data(args: list[str], cwd: str = '', extra_args: tuple[str, ...] = ()) -> SSHConnectionData | None:\n    boolean_ssh_args, other_ssh_args = get_ssh_cli()","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/ssh/utils.py#L287-L323","documentation":"set_server_args_in_cmdline() rebuilds an ssh command line by matching each option against a table of known ssh options (that specify whether it takes a value, is a flag, etc.). When an argument starting with '-' isn't found in the table, it raises KeyError(f'unknown option -- {arg[1:]}') — the KeyError message text is the unknown ssh option name. It is called via modify_argv_for_launch_with_cwd() when the ssh kitten prepares to launch ssh.","triggerScenarios":"Passing an ssh command line containing an option kitty's option table doesn't know — typically new/obscure ssh flags (`-O`, newer OpenSSH options, vendor-specific flags), or a malformed arg like `-` followed by unexpected text. The loop consumes the table entry's value or sets expecting_option_val; no entry means KeyError.","commonSituations":"Using a newer OpenSSH client with options kitty hasn't catalogued in this version; passing through unusual options in SSH config aliases expanded onto the command line; typos like `-pOrt` or concatenated short options that kitty's parser can't split; running an older kitty with a newer system ssh.","solutions":["Update kitty to the latest version — new ssh options are regularly added to its option table.","Remove/avoid the unrecognized ssh option on the kitten ssh command line (put exotic options in ~/.ssh/config instead of argv).","If the option must stay and you're on latest kitty, report it upstream so the table gains the option; as a local patch add it to the option table in kittens/ssh/utils.py.","Check for typos/malformed dashes in the ssh invocation."],"exampleFix":"# before\nkitten ssh -O forward user@host  # KeyError: unknown option -- O (if unknown to kitty's table)\n\n# after\n# move it into ~/.ssh/config or update kitty\nkitten ssh user@host","handlingStrategy":"try-catch","validationCode":"import kittens.ssh.utils as u\n\ndef safe_set_server_args(cmdline: list[str]) -> list[str]:\n    args = [a for a in cmdline if not (a.startswith('-') and a.lstrip('-') not in KNOWN_OPTS)]\n    return u.set_server_args_in_cmdline(args)  # pre-filter unknown options","typeGuard":null,"tryCatchPattern":"try:\n    set_server_args_in_cmdline(cmdline)\nexcept KeyError as e:\n    bad = e.args[0]  # e.g. 'unknown option -- XYZ'\n    # drop the offending option (and its value) and retry, or fall back to plain ssh\n    subprocess.call(['ssh', *cmdline])","preventionTips":["Put exotic/new ssh options in ~/.ssh/config instead of the command line when using kitten ssh.","Keep kitty updated alongside your OpenSSH client so its option table stays current.","Sanitize user-supplied ssh args (validate against the known option table) before passing to the ssh kitten."],"tags":["kitty","ssh","unknown-option","argv-parsing","keyerror"],"backgroundTag":"unknown-cli-option","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}