-
Notifications
You must be signed in to change notification settings - Fork 0
Description
cliui.Prompt()
uses a buffered reader to read until the first newline to capture one "line" of input from terminal user.
However, if the input fails validation, it re-entrantly calls Prompt()
to ask the user for more input. If the original buffered reader has read and buffered some input after the newline, this input is lost and inaccessible to the new Prompt()
call.
I believe this is the root cause of errors like this in our validation test: https://github.com/coder/coder/actions/runs/11681622439/job/32527173007
This is a legit bug in our product, but it is unlikely to come up in normal human use of the CLI, since the missing input would have to be available immediately after the newline. That's why I've raised this in coder/internal instead of coder/coder. It could still plausibly come up if someone is interacting with our CLI via an expect
-style library, but I would hope our flag options generally make that unnecessary.
We should still fix it for the sake of test flakes.