fix(tasks): bypass Invoke PTY for interactive superuser/flush commands#12078
Open
getpwnam wants to merge 2 commits into
Open
fix(tasks): bypass Invoke PTY for interactive superuser/flush commands#12078getpwnam wants to merge 2 commits into
getpwnam wants to merge 2 commits into
Conversation
Docker TTY sessions could drop the first keypress and stall at the username prompt when using invoke superuser (and interactive flush). Run these interactive management commands via direct subprocess stdio instead of Invoke PTY mediation. Refs inventree#11751.
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
Member
|
Hi @getpwnam ! Throwing walls of LLM-generated text against maintainers is a waste of everybody's time, waste of ressources and bad faith; keep it short and human to avoid getting code-of-coducted on your next PR and in the following interactions. |
matmair
requested changes
Jun 3, 2026
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.
Summary
This PR fixes an interactive CLI regression where
invoke superuser(and interactive delete_data/flush) can drop the first typed character and then stall at the username/confirmation prompt in Docker terminal sessions.The fix routes these specific interactive commands through a direct subprocess call (
python3 manage.py ...) with inherited stdio instead of Invoke’s PTY execution path.Closes: #11751
Problem
In affected Docker environments, running interactive commands via Invoke task execution shows:
This was reproducible for:
But raw Django interactive command worked in the same container:
docker compose exec -it inventree-server python3 manage.py createsuperuser -v 0That isolates the issue to the Invoke-mediated interactive path, not Django createsuperuser itself.
Reproduced Environment
contrib/container/docker-compose.yml)INVENTREE_TAG=1.3.03.14.32.2.1Raw
manage.py createsuperuserworked in the same environment, isolating the issue to the Invoke-mediated task path.Why this happens
Invoke with pty=True performs its own stdin/TTY mediation (character-buffered input loop, stdin polling, PTY handling). In Docker interactive sessions, this adds an extra terminal mediation layer on top of Docker’s TTY handling. In some runtime combinations, this leads to input timing/forwarding issues (observed as dropped first character and prompt stalls).
Interactive input through the Invoke PTY path seems fragile here, while direct process stdio is stable.
Fix approach
For interactive management commands only:
manage_interactive(...)helper that executespython3 manage.py ...viasubprocess.run(...)with inherited stdio.manage_interactive('createsuperuser')in superuser.manage_interactive('flush')for the interactive (non-force) delete_data path.Why this is appropriate
Narrow scope: only touches commands that require interactive stdin behavior.
Preserves UX: invoke superuser remains interactive and now matches direct Django CLI behavior.
Evidence-based: raw Django interactive works in the same environment; only Invoke-mediated path fails.
Lower risk than broad task-runner changes.
Validation performed
Reproduced failure mode for invoke superuser in Docker interactive sessions.
Confirmed raw
manage.py createsuperuserworks in same environment.Verified updated task code compiles and follows existing command error handling patterns.
Confirmed behaviour rationale in changelog update.
invoke superusertested successfully (interactive input accepted correctly; no dropped first character; prompt flow completed).invoke dev.delete-datatested successfully in interactive mode (confirmation input accepted correctly).Files changed
tasks.pyCHANGELOG.md