fix: report a Redis database number too long for int() to read

The ASCII-digit check accepts any length, but since 3.11 Python refuses to
convert a digit string past its conversion limit, so a long one raised
ValueError straight through the CLI instead of the message every other
unusable URL gets.
This commit is contained in:
Alex committed 2026-09-17 00:23:24 +01:00
1 parent 0d153d3c0d
commit 147bb352ec
2 files changed
+16 -1

No files matched your search

+7
View File
@@ -224,6 +224,13 @@ class TestNativeUp:
assert env["CELERY_BROKER_URL"] == "redis://[::1]:6379/2"
assert env["CACHE_REDIS_URL"] == "redis://[::1]:6379/4"
def test_a_redis_database_number_too_long_to_convert_is_reported(self, tmp_path):
"""Since 3.11 int() refuses a digit string past its limit, which the digit check let through."""
argv = ["up", "--native", "--dir", str(tmp_path), "--yes", "--postgres-uri", "postgresql://localhost/d",
"--redis-url", "redis://localhost:6379/" + "1" * 5000]
with pytest.raises(DeployError, match="too long to read"):
_run(argv, _native_context())
@pytest.mark.parametrize("url", ["localhost:6379", "redis+socket:///var/run/redis.sock",
"redis://localhost:6379/queue"])
def test_a_redis_url_that_cannot_be_numbered_is_refused(self, tmp_path, url):