Skip to content

kapp reads confirmation prompt from stdin not tty #1003

@ringerc

Description

@ringerc

What steps did you take:

simplified example (real case uses a json input not jq --null-input):

#!/bin/bash -e -u -o pipefail
jq -r --null-input '["app1","app2"]|.[]' | while read -r app; do
  kapp deploy -a "$app" -f "manifests/$app.yaml"
done

What happened:

Op:      ...
Wait to: ...

Continue? [yN]: app1
invalid input (not y, n, yes, or no)
Continue? [yN]: app2
invalid input (not y, n, yes, or no)

What did you expect:

kapp to prompt for confirmation and read input from the tty since --yes was not passed.

Anything else you would like to add:

The bug here is that kapp tries to read interactive confirmation from stdin. That's rarely correct; the user may

kustomize build foo | kapp deploy -f -`

for example. But within the while loop, stdin points to the output of the jq command. kapp wasn't given -f - or anything so it isn't expected to read from stdin.

It should do what sudo and other tools do - detect an interactive tty and read directly from the tty, rather than stdin.

Workaround

To work around the bug, dup the stdin fd before you enter the loop or pass the pipe, e.g.

#!/bin/bash -e -u -o pipefail
# save stdin fd, so we can tell kapp to use it for prompting
exec 3<&0
jq -r --null-input '["app1","app2"]|.[]' | while read -r app; do
  # pass kapp the original stdin
  kapp deploy -a "$app" -f "manifests/$app.yaml" <&3
done

or

#!/bin/bash -e -u -o pipefail
exec 3<&0
kustomize build foo | kapp deploy -a myapp -f -

Environment:

  • kapp version 0.63.2
  • Ubuntu 24.04 LTS
  • Kubernetes Server Version: v1.29.2

Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue describes a defect or unexpected behaviorcarvel acceptedThis issue should be considered for future work and that the triage process has been completed

    Type

    No type

    Projects

    Status

    Unprioritized

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions