{"record":{"id":"24a2e17523683f4e","repo":"kovidgoyal/kitty","slug":"not-a-valid-file-descriptor-number-v","errorCode":null,"errorMessage":"not a valid file descriptor number: %#v","messagePattern":"not a valid file descriptor number: %#v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/clipboard/main.go","lineNumber":53,"sourceCode":"\t\t}\n\t\tswitch ptype {\n\t\tcase \"text\":\n\t\t\topts.Password = val\n\t\tcase \"fd\":\n\t\t\tif fd, err := strconv.Atoi(val); err == nil {\n\t\t\t\tif f := os.NewFile(uintptr(fd), \"password-fd\"); f == nil {\n\t\t\t\t\treturn 1, fmt.Errorf(\"invalid file descriptor: %d\", fd)\n\t\t\t\t} else {\n\t\t\t\t\tdata, err := io.ReadAll(f)\n\t\t\t\t\tf.Close()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn 1, fmt.Errorf(\"failed to read from file descriptor: %d with error: %w\", fd, err)\n\t\t\t\t\t}\n\t\t\t\t\topts.Password = strings.TrimRightFunc(string(data), unicode.IsSpace)\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\treturn 1, fmt.Errorf(\"not a valid file descriptor number: %#v\", val)\n\t\t\t}\n\t\tcase \"file\":\n\t\t\tif data, err := os.ReadFile(val); err == nil {\n\t\t\t\topts.Password = strings.TrimRightFunc(string(data), unicode.IsSpace)\n\t\t\t} else {\n\t\t\t\treturn 1, fmt.Errorf(\"failed to read from file: %#v with error: %w\", val, err)\n\t\t\t}\n\t\t}\n\t}\n\tif len(args) > 0 {\n\t\treturn 0, run_mime_loop(opts, args)\n\t}\n\tif opts.Password != \"\" || opts.HumanName != \"\" {\n\t\treturn 1, fmt.Errorf(\"cannot use --human-name or --password in filter mode\")\n\t}\n\treturn 0, run_plain_text_loop(opts)\n}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/clipboard/main.go#L35-L71","documentation":"For --password fd:VALUE, the part after 'fd:' must parse as an integer via strconv.Atoi. When it does not (Atoi returns an error), the raw value is reported as not a valid file descriptor number.","triggerScenarios":"Passing `--password fd:abc`, `--password fd:3a`, `--password fd:` (empty), or any non-numeric value after the fd: prefix.","commonSituations":"Typos such as `fd:0x3` or `fd: 3` (leading space); passing a filename instead of a number after fd: because the user meant the file: type; copy-paste from examples that used a different syntax.","solutions":["Use a plain decimal integer: `--password fd:3`","If you meant a path, switch the type: `--password file:/path/to/pw`","Trim any accidental whitespace or shell-expanded characters from the value"],"exampleFix":"# before\nkitten clipboard get --human-name me --password fd:/tmp/pw\n# after\nkitten clipboard get --human-name me --password file:/tmp/pw","handlingStrategy":"validation","validationCode":"val=${PW#fd:}\n[[ \"$val\" =~ ^[0-9]+$ ]] || { echo 'fd: value must be an integer'; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the fd suffix is numeric in wrappers","Use file: when tempted to pass a path after fd:"],"tags":["kitty","clipboard","cli-arguments","file-descriptor","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}