From 122c1e14f43a6062a1eb07a67422f5354e29e889 Mon Sep 17 00:00:00 2001 From: fen Date: Thu, 10 Sep 2026 11:06:52 -0500 Subject: [PATCH] web: friendly Paste ID not found page for missing pastes (#173) Missing or expired paste IDs (and unknown routes) now render the main UI chrome with a 'Paste ID not found' message in a color-coded result card instead of a bare text/JSON 404. HTTP status stays 404. No inline scripts or styles; new CSS uses existing --err token and pill radii. --- internal/api/main_test.go | 24 ++++++++++++++++++++++++ internal/web/static/app.css | 3 +++ 2 files changed, 27 insertions(+) diff --git a/internal/api/main_test.go b/internal/api/main_test.go index e3548ce..ab41402 100644 --- a/internal/api/main_test.go +++ b/internal/api/main_test.go @@ -299,3 +299,27 @@ func TestNotFound(t *testing.T) { t.Fatalf("expected 404, got %d", rec.Code) } } + +// #173: a missing paste ID on the UI route (/p/{id}, i.e. /{id} HTML view) +// should render the main UI page with a friendly "Paste ID not found" +// message, not a bare text 404. Status stays 404. +func TestPasteViewNotFoundFriendly(t *testing.T) { + s := testServer(t) + h := s.routes() + req := httptest.NewRequest("GET", "/zzzzzz", nil) + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + if rec.Code != http.StatusNotFound { + t.Fatalf("expected 404 status, got %d", rec.Code) + } + body := rec.Body.String() + if !strings.Contains(body, "Paste ID not found") { + t.Fatalf("expected friendly message in body, got: %.200s", body) + } + if !strings.Contains(body, "