Skip to content

IsInteractive treats /dev/null as a terminal #55

Description

@cretz

#50 (comment)

CommandContext.IsInteractive (internal/cmd/command_context.go) decides by checking fi.Mode()&os.ModeCharDevice, but /dev/null is a character device without being a terminal, so it reports true.

Effect: baseten loops run deactivate --run-id X </dev/null slips past the --yes guard and tries to prompt. In an interactive shell it opens /dev/tty and prompts even though the help says --yes is required; in cron or CI, where stdin is often /dev/null, it dies with huh: could not open a new TTY: open /dev/tty: device not configured instead of the "pass --yes" usage error.

Six call sites are affected, not just the confirmation guard: four in command.auth.go (device-flow login, profile selection), plus org secret and model.

Fix is term.IsTerminal(int(f.Fd())) from golang.org/x/term, already in go.sum transitively and needing promotion to a direct dependency. The auth paths should be exercised since their behavior changes too.

Reported by @spal1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions