{"record":{"id":"59731e0f0904863e","repo":"kovidgoyal/kitty","slug":"unknown-extra-argument-s-supplied-to-s","errorCode":null,"errorMessage":"Unknown extra argument(s) supplied to %s","messagePattern":"Unknown extra argument\\(s\\) supplied to (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kitty/rc/base.py","lineNumber":227,"sourceCode":"    args_choices: Callable[[], Iterable[str]] | None = None\n\n    @property\n    def args_count(self) -> int | None:\n        if not self.spec:\n            return 0\n        return self.count\n\n    def as_go_completion_code(self, go_name: str) -> Iterator[str]:\n        c = self.args_count\n        if c is not None:\n            yield f'{go_name}.StopCompletingAtArg = {c}'\n        if self.completion:\n            yield from self.completion.as_go_code(go_name + '.ArgCompleter', ' = ')\n\n    def as_go_code(self, cmd_name: str, field_types: dict[str, str], handled_fields: set[str]) -> Iterator[str]:\n        c = self.args_count\n        if c == 0:\n            yield f'if len(args) != 0 {{ return fmt.Errorf(\"%s\", \"Unknown extra argument(s) supplied to {cmd_name}\") }}'\n            return\n        if c is not None:\n            yield f'if len(args) != {c} {{ return fmt.Errorf(\"%s\", \"Must specify exactly {c} argument(s) for {cmd_name}\") }}'\n        if self.value_if_unspecified:\n            yield 'if len(args) == 0 {'\n            for x in self.value_if_unspecified:\n                yield f'args = append(args, \"{x}\")'\n            yield '}'\n        if self.minimum_count > -1:\n            if self.minimum_count == 1:\n                yield f'if len(args) < {self.minimum_count} {{ return fmt.Errorf(\"%s\", \"Must specify at least one argument to {cmd_name}\") }}'\n            else:\n                yield f'if len(args) < {self.minimum_count} {{ return fmt.Errorf(\"%s\", \"Must specify at least {self.minimum_count} arguments to {cmd_name}\") }}'\n        if self.args_choices:\n            achoices = tuple(self.args_choices())\n            yield 'achoices := map[string]bool{' + ' '.join(f'\"{x}\":true,' for x in achoices) + '}'\n            yield 'for _, a := range args {'\n            yield 'if !achoices[a] { return fmt.Errorf(\"Not a valid choice: %s. Allowed values are: %s\", a, \"' + ', '.join(achoices) + '\") }'","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/rc/base.py#L209-L245","documentation":"Generated into the Go handlers for remote control (RC) commands by kitty/rc/base.py: when a command declares args_count == 0 (it takes no positional arguments) but the incoming payload contains positional args, the handler rejects them with this error naming the command.","triggerScenarios":"Sending a remote control command via kitty @ that accepts no positional args but including them, e.g. 'kitten @ new-window extra-arg' for a zero-arg command, or a socket payload whose \"args\" array is non-empty for a 0-arg command.","commonSituations":"Scripting kitty @ commands and miscounting which flags vs positional args a command takes; version changes where a command gained/lost positional args; copy-pasted shell commands with trailing words treated as args.","solutions":["Remove the extra positional arguments from the command","Check kitty @ <cmd> --help for the exact argument signature in your version","Put values in options/flags (--flag value) rather than positional words when the command expects none","Quote and validate constructed command lines in scripts before sending them"],"exampleFix":"# before\nkitten @ set-window-title main \"My Title\"\n\n# after\nkitten @ set-window-title \"My Title\"","handlingStrategy":"validation","validationCode":"if cmd.ArgsCount == 0 && len(args) > 0 {\n    return fmt.Errorf(\"%s takes no positional arguments; got %v\", cmd.Name, args)\n}","typeGuard":"func takesNoArgs(argsCount int) bool { return argsCount == 0 }","tryCatchPattern":"if err := runRCCommand(cmd, args); err != nil {\n    if strings.Contains(err.Error(), \"Unknown extra argument\") {\n        return fmt.Errorf(\"usage: %s (no positional args)\", cmd)\n    }\n    return err\n}","preventionTips":["Read kitty @ <cmd> --help before scripting","Prefer flags over positional words where supported","Assert arg counts in RC wrapper scripts"],"tags":["kitty","remote-control","arguments","validation","generated-code"],"backgroundTag":"unexpected-command-arguments","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}