Repository navigation
Accept a pasted connection JSON at the env set prompt - #2299
Merged
Merged
Conversation
The value prompt read with term.ReadPassword, which uses the terminal's
line mode. Pretty-printed JSON ended at its first newline and arrived as
a lone "{", and macOS caps a line in that mode at 1024 bytes and drops
the rest, Enter included, so a pasted service-account key left the
prompt hanging.
input.HiddenValue reads in raw mode instead. Enter ends the value except
inside a JSON object or array that is still open, so a multi-line paste
ends where the JSON does, and Ctrl-D ends it anywhere.
Co-Authored-By: Claude <noreply@anthropic.com>
Coverage Report for CI Build 38187551759Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.03%) to 57.706%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Review follow-ups for the hidden value prompt:
- The open-JSON rule swallowed Enter for any value starting with an
unclosed { or [, a password included, and did nothing for a non-JSON
multi-line paste such as a PEM key, whose later lines ran as shell
commands. The prompt now turns on bracketed paste: newlines inside a
paste are part of the value, a typed Enter ends it, and a paste ending
in a newline ends it as pasting a line always has.
- Ctrl-C exited 1. cliout.ExitCode now maps input.ErrInterrupted to 130.
- input.Password, behind the cloud env prompt and APC auth, still used
term.ReadPassword and had the same paste bugs. It uses HiddenValue.
- Reads are one byte at a time, so nothing past the value is taken off
the terminal and lost.
- ESC O sequences (function keys, application-mode arrows) are skipped,
and a bare Esc no longer eats the key after it.
- SIGTERM and SIGHUP put the terminal back before exiting, so a killed
prompt does not leave the shell without echo.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pasting a connection into the
astro local env connection setprompt failed two ways, both reproduced under a pty:{(and the rest of the paste ran as shell commands).term.ReadPasswordreads in the terminal's line mode, and macOS caps a line there at 1024 bytes, dropping the rest, Enter included.input.HiddenValuereads in raw mode instead, which has no line limit, and turns on bracketed paste so a paste can be told from typing: newlines inside a paste are part of the value, a typed Enter ends it, and a paste ending in a newline ends it. A terminal without bracketed paste falls back to the old behaviour (a newline ends the value).Also:
input.Passworduses it too, so the cloudastro envprompt and APC auth get the same fix.cliout.ExitCodemapsinput.ErrInterrupted).Checked: unit tests over the byte stream; a pty run of
astro local env connection setwith a typed value, a 1570-byte line, a bracketed pretty-printed paste (with and without a trailing newline), an unbracketed multi-line paste, a typed{p@ss, and Ctrl-C (exit 130);GOOS=windowsbuild/vet/golangci-lint;make deadcode.