From a59ded784dfac4908562ad134051ad1229603190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20ROBERT?= Date: Tue, 15 Sep 2026 09:53:40 +0200 Subject: [PATCH] fix(scaleway): a comment about the gateway's 404 outlived the line that fixed it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestTheGatewayMetadataDoesNotVary carried a note saying that a POST to `/metadata` answers net/http's plain-text "404 page not found", that the real gateway answers a Scaleway error document there, and that the divergence was left to #776. All three sentences were true when they were written and the first was false by the time they were committed: declaring `/metadata` in productPrefixes — in the same change — is exactly what stops that path falling through to net/http. The comment described a state its own pull request had removed. Measured both ways on 2026-09-15: without the prefix 404 page not found (text/plain) with it 501 {"type":"not_emulated", …} So the assertion is strengthened rather than the comment reworded. It was "not 200", which passes for a bare status the SDK drops; it now names the refusal this pack owes a client inside its declared space, which is #74's finding and the reason the prefix list exists. The existing mutation on that prefix reddens TestEveryRouteFallsUnderADeclaredPrefix, which is a statement about the route table. This adds the one that reddens the behaviour a client sees, and it bites: seven mutations, all of them. Assisted-by: Claude Code (claude-opus-5) --- internal/providers/scaleway/gateway_test.go | 29 ++++++++++--------- .../the-gateway-is-served-and-scanned.json | 8 +++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/internal/providers/scaleway/gateway_test.go b/internal/providers/scaleway/gateway_test.go index d830b55..382a9ad 100644 --- a/internal/providers/scaleway/gateway_test.go +++ b/internal/providers/scaleway/gateway_test.go @@ -69,19 +69,22 @@ func TestTheGatewayMetadataDoesNotVary(t *testing.T) { // And it is a GET: the SDK issues no other verb at this path, so anything // else must not be served here by accident. // - // Read with a bare client rather than the shared helper, which decodes JSON - // and fails on this answer — because an unmounted path answers net/http's - // plain-text "404 page not found". The real gateway answers a Scaleway error - // document there (`{"type":"404","message":…}`, measured 2026-09-14). That - // divergence is real and belongs to every unmounted path rather than to this - // route, so it is named in #776 and not fixed here; this assertion is about - // the verb, and it is written not to depend on a body it is not judging. - res, err := ts.Client().Post(ts.URL+"/metadata", "application/json", nil) //nolint:noctx // test client - if err != nil { - t.Fatalf("POST /metadata: %v", err) - } - defer func() { _ = res.Body.Close() }() - if res.StatusCode == http.StatusOK { + // What it answers instead is this pack's own refusal, and that is worth + // asserting rather than merely "not 200": declaring `/metadata` in + // productPrefixes is what buys it. Before that line, a POST here fell + // through to net/http and came back as plain-text "404 page not found" — + // which the SDK drops, leaving a caller with a bare status and nothing to + // branch on. That is #74's finding, and this route is inside it. + // + // Measured both ways on 2026-09-15: without the prefix, `404 page not + // found`; with it, `501 {"type":"not_emulated", …}`. + status, body := do(t, ts, "POST", "/metadata", "") + if status == http.StatusOK { t.Error("POST /metadata answered 200; the gateway serves a read") } + if body["type"] != "not_emulated" { + t.Errorf("POST /metadata answered %v, not this pack's refusal. A path inside "+ + "a declared prefix must answer in Scaleway's dialect, or the SDK drops "+ + "the body and the caller gets a bare status", body) + } } diff --git a/tools/falsify/specs/the-gateway-is-served-and-scanned.json b/tools/falsify/specs/the-gateway-is-served-and-scanned.json index 24837ea..65c7911 100644 --- a/tools/falsify/specs/the-gateway-is-served-and-scanned.json +++ b/tools/falsify/specs/the-gateway-is-served-and-scanned.json @@ -47,6 +47,14 @@ "find": "\t\"/metadata\",", "replace": "\t\"/metadata-not-declared\",", "test": "TestEveryRouteFallsUnderADeclaredPrefix" + }, + { + "label": "the gateway path leaves the declared space, so a POST near it answers net/http's plain text and the SDK hands its caller a bare status", + "file": "internal/providers/scaleway/pack.go", + "package": "./internal/providers/scaleway/", + "find": "\t\"/metadata\",", + "replace": "\t\"/metadata-not-declared-either\",", + "test": "TestTheGatewayMetadataDoesNotVary" } ] }