kovidgoyal/kitty · error
not a valid file descriptor number: %#v
Error message
not a valid file descriptor number: %#v
What it means
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.
Source
Thrown at kittens/clipboard/main.go:53
}
switch ptype {
case "text":
opts.Password = val
case "fd":
if fd, err := strconv.Atoi(val); err == nil {
if f := os.NewFile(uintptr(fd), "password-fd"); f == nil {
return 1, fmt.Errorf("invalid file descriptor: %d", fd)
} else {
data, err := io.ReadAll(f)
f.Close()
if err != nil {
return 1, fmt.Errorf("failed to read from file descriptor: %d with error: %w", fd, err)
}
opts.Password = strings.TrimRightFunc(string(data), unicode.IsSpace)
}
} else {
return 1, fmt.Errorf("not a valid file descriptor number: %#v", val)
}
case "file":
if data, err := os.ReadFile(val); err == nil {
opts.Password = strings.TrimRightFunc(string(data), unicode.IsSpace)
} else {
return 1, fmt.Errorf("failed to read from file: %#v with error: %w", val, err)
}
}
}
if len(args) > 0 {
return 0, run_mime_loop(opts, args)
}
if opts.Password != "" || opts.HumanName != "" {
return 1, fmt.Errorf("cannot use --human-name or --password in filter mode")
}
return 0, run_plain_text_loop(opts)
}
View on GitHub (pinned to 6d5d0c4406)
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
Example fix
# before kitten clipboard get --human-name me --password fd:/tmp/pw # after kitten clipboard get --human-name me --password file:/tmp/pw
Defensive patterns
Strategy: validation
Validate before calling
val=${PW#fd:}
[[ "$val" =~ ^[0-9]+$ ]] || { echo 'fd: value must be an integer'; exit 2; } Prevention
- Validate the fd suffix is numeric in wrappers
- Use file: when tempted to pass a path after fd:
When it happens
Trigger: Passing `--password fd:abc`, `--password fd:3a`, `--password fd:` (empty), or any non-numeric value after the fd: prefix.
Common situations: 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.
Related errors
- %s is not valid MIME alias specification
- must specify --human-name when using a password
- invalid password: %#v no password type specified
- invalid file descriptor: %d
- failed to read from file descriptor: %d with error: %w
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/24a2e17523683f4e.
Report an issue: GitHub.