﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37561	createsuperuser tests infinite loop without a system username	Mike Edmunds		"In `tests/auth_tests/test_management.py`, `CreatesuperuserManagementCommandTestCase.test_default_username` and `MultiDBCreatesuperuserTestCase.test_createsuperuser_command_suggested_username_with_database_option` assume a default username is available. If `django.contrib.auth.management.get_default_username()` returns an empty string, the tests will repeatedly attempt to pass a blank username to the `createsuperuser` command, which rejects it with `Error: This field cannot be blank.`. And they'll keep at it until someone kills the test run (or GitHub times it out).

One way this can occur is running Django's test suite in a container with a numeric UID that doesn't correspond to a known container user. (Using runtest.py's `--noinput` doesn't prevent the problem because the tests explicitly invoke the management command interactively.)

To reproduce with django-docker-box, using the non-existent UID 4321:

{{{#!shell
docker compose run --rm --user 4321:4321 sqlite \
  --noinput auth_tests.test_management

# Or with podman:
podman-compose --podman-run-args='--passwd=false' \
  run --rm --user 4321:4321 sqlite \
  --noinput auth_tests.test_management
}}}

(Docker doesn't automatically create container users for unknown ids; podman does unless you specify `--passwd=false`.)

'''Results:'''

{{{#!text
...
Error: This field cannot be blank.
Error: This field cannot be blank.
Error: This field cannot be blank.
Error: This field cannot be blank.
Error: This field cannot be blank.
Error: This field cannot be blank.
Error: This field cannot be blank.
...
}}}

'''Expected:''' successful test run

'''Workaround:''' set `LOGNAME` in the environment so `get_system_username()` won't return blank. E.g.:

{{{#!shell
podman-compose --podman-run-args='--passwd=false' \
  run --rm --user 4321:4321 --env LOGNAME=test sqlite \
  --noinput auth_tests.test_management
}}}

(I'm not sure this is worth fixing, but am creating the issue to document the behavior and workaround. I ran into it while trying to get django-docker-box tests running in a GitHub workflow. AI disclosure: Junie/GPT-6.1 Terra assisted in finding the cause and workaround, and in clarifying behavioral differences between podman and docker.)
"	Cleanup/optimization	new	contrib.auth	dev	Low				Unreviewed	0	0	0	0	0	0
