fix(6255): Test destination names an address that did not answer as S3
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 55s
CI & Build / integration (push) Successful in 1m5s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 23s

A 4xx with no S3 error body came from something else at that address, most
often a web server on the default port. The message now says so and to check
the scheme and port, beside the raw status. A 5xx without a body keeps its
own reason, since a busy S3 service can answer that way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 20:03:52 -04:00
co-authored by Claude Opus 5.5
parent d51ccd9b69
commit 0a4eb313fe
2 changed files with 22 additions and 0 deletions
+16
View File
@@ -78,6 +78,22 @@ def test_a_refusal_says_why(tmp_path):
asyncio.run(s3.put_file(TARGET, "b.tar", f, transport=transport))
def test_a_web_server_at_the_address_is_named_as_not_s3():
"""No port in the address: the request lands on whatever serves port 80,
and its plain 404 says nothing about S3."""
page = b"<html><body><h1>404 Not Found</h1></body></html>"
transport = httpx.MockTransport(lambda r: httpx.Response(404, content=page))
with pytest.raises(s3.S3Error, match=r"HTTP 404: the address answered, but not as S3 — check the scheme and the port"):
asyncio.run(s3.list_objects(TARGET, transport=transport))
def test_a_server_error_without_a_body_is_not_blamed_on_the_port():
transport = httpx.MockTransport(lambda r: httpx.Response(503))
with pytest.raises(s3.S3Error, match="HTTP 503: Service Unavailable") as err:
asyncio.run(s3.list_objects(TARGET, transport=transport))
assert "port" not in str(err.value)
def test_unreachable_says_so(tmp_path):
f = tmp_path / "b.tar"
f.write_bytes(b"x")