From 17b9b5b031af129fbfa0f2c9e2550166b69be5e8 Mon Sep 17 00:00:00 2001 From: Gaoshou101 Date: Sat, 7 Nov 2026 21:04:12 +0800 Subject: [PATCH] gateway: TestSearchAPIFailureKeepsNoURL's query has no number a port can hold (#5616) Fixes #5616 Ubuntu CI run 42368406605 failed it: "the query's "4410" is in usage.jsonl", where the only 4410 was the fake server's random port, host 127.0.0.1:44105. The row rightly logs the host, so a query word made of digits matches the port now and then. The query is letters only now, as 4a4a82cd4 did for the sibling TestSearchAPIAsksAreLogged; the check that no query word reaches usage.jsonl is unchanged, and the new word still rides in the GET URL, so a leaked URL still fails it. Test-only; no gateway code changes. Broken by hand: the untouched test with the fake server's listener pinned to 127.0.0.1:44105 (throwaway harness, not committed) fails with the CI message: the query's "4410" is in usage.jsonl. With this change and the same pin it passes. Run at this tree (origin/main 56f095604 + this): go test -tags nogui -race -count=20 -run 'TestSearchAPI|TestOwnSearchIsLogged' ./internal/gateway ok. GOOS=linux go vet -tags nogui ./internal/gateway and GOOS=windows go vet ./internal/gateway clean; gofmt -l and git diff --check clean. Not run: the whole gateway package (one-line test literal change). --- internal/gateway/search_api_log_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/gateway/search_api_log_test.go b/internal/gateway/search_api_log_test.go index c07b3719a..8667196d9 100644 --- a/internal/gateway/search_api_log_test.go +++ b/internal/gateway/search_api_log_test.go @@ -123,7 +123,9 @@ func TestSearchAPIAsksAreLogged(t *testing.T) { // errors say whole: the row says the host and what went wrong, not the URL. func TestSearchAPIFailureKeepsNoURL(t *testing.T) { fresh(t) - const query = "wombat lattice 4410" + // letters only: a number could be in the server's random port + // (127.0.0.1:44105 held "4410" on ubuntu CI, #5616) + const query = "wombat lattice numbatzor" srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { c, _, err := w.(http.Hijacker).Hijack() if err == nil {