Credentials input not working with contex.run from within a Devcontainer
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start by running the provided reproduction script inside a VSCode devcontainer, then trace Context.run with in_stream=True and pty=True/False, including the interaction with Python's input() and getpass(). Done means username and password entry work correctly without the first character being swallowed or the password prompt becoming unresponsive.
Written by the indexing model from the issue text.
Description
While I found several different issues where something related to stdin did or does not work - this one does not seem to be covered, yet:
What happens:
Entering user name/pw from stdin to programm started with c.run does not work. What (mostly) happens:
- First character gets swallowed somehow. Have to press the first character twice. Found some issues about that one. And: Looks ike
in_stream=Falsemakes the first character appear on the first key press. - PW entry not working: When running inside the devcontainer, after pressing enter to confirm the user name, the password prompt is missing, and nothing happens when I press any key.
pty=True/Falsedoes not seem to have an effectin_stream=Falsewill avoid the 'first-character-gets-swallowed` problem, but still not fix the passwort-entry-problem
You should be able to use the following script to reproduce the issue - when executed from within a devcontainer in VSCode:
import shlex
import sys
import textwrap
from invoke import Context
INNER_SCRIPT = textwrap.dedent(
"""
from getpass import getpass
print('=== Please enter your USERNAME ===', flush=True)
username = input()
print('=== Please enter your PASSWORD ===', flush=True)
password = getpass('')
print(f'You entered username: {username}')
print(f'You entered password: {password}')
"""
).strip()
print(">>> running via invoke Context.run(pty=True)")
cmd = f"{shlex.quote(sys.executable)} -c {shlex.quote(INNER_SCRIPT)}"
Context().run(cmd, in_stream=True)
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 412
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pyinvoke/invoke
-
[Security] Shell injection via Context.cd() path argument — metacharacters not escaped (CWE-78) Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Similar issues
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openml/openml-python#1749 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sipyourdrink-ltd/bernstein#6191 ·