···184184 loadWG.Wait()
185185186186 if recipe.OriginHash == "" {
187187- slog.WarnContext(ctx, "recipe missing origin hash Probably and old recipe", "hash", hash)
188188- p := DefaultParams(&locations.Location{
189189- ID: "",
190190- Name: "Unknown Location",
191191- }, time.Now())
192192- FormatRecipeHTML(ctx, p, *recipe, signedIn, hasRecipeImage, thread, feedback, wineRecommendation, w)
187187+ slog.ErrorContext(ctx, "No origin hash for recipe", "hash", hash, "error", err)
188188+ http.Error(w, "recipe not found or expired", http.StatusInternalServerError)
193189 return
194190 }
195191 // we didn't go back and update old recipes's with new hash so have to handle that here. Could still backfill
···200196 }
201197 p, err := s.ParamsFromCache(ctx, recipe.OriginHash)
202198 if err != nil {
203203- slog.ErrorContext(ctx, "failed to load params for hash", "hash", recipe.OriginHash, "error", err)
204204- // http.Error(w, "recipe not found or expired", http.StatusNotFound)
205205- // return
206206- p = DefaultParams(&locations.Location{
207207- ID: "",
208208- Name: "Unknown Location",
209209- }, time.Now())
199199+ slog.ErrorContext(ctx, "failed to load params for hash", "origin hash", recipe.OriginHash, "hash", hash, "error", err)
200200+ http.Error(w, "recipe not found or expired", http.StatusInternalServerError)
201201+ return
210202 }
211203212204 if p.ConversationID == "" {
+3-10
internal/recipes/server_test.go
···386386 }
387387}
388388389389-func TestHandleSingle_LegacyOriginHashDoesNotFailWhenParamsMissing(t *testing.T) {
389389+func TestHandleSingle_LegacyOriginHashFailWhenParamsMissing(t *testing.T) {
390390 cacheStore := cache.NewFileCache(filepath.Join(t.TempDir(), "cache"))
391391 s := newTestServer(t, withTestCache(cacheStore))
392392···419419420420 s.handleSingle(rr, req)
421421422422- if rr.Code != http.StatusOK {
423423- t.Fatalf("expected status %d, got %d", http.StatusOK, rr.Code)
424424- }
425425- body := rr.Body.String()
426426- if !strings.Contains(body, "/recipes?h="+canonicalHash) {
427427- t.Fatalf("expected canonical back-link hash %q in response body: %s", canonicalHash, body)
428428- }
429429- if !strings.Contains(body, "Unknown Location") {
430430- t.Fatalf("expected fallback params rendering with Unknown Location, body: %s", body)
422422+ if rr.Code != http.StatusInternalServerError {
423423+ t.Fatalf("expected status %d, got %d", http.StatusInternalServerError, rr.Code)
431424 }
432425}
433426