oficina / fichas Public

Pin the page read's failure as a 503, never the reset (Fable's review of d0c7761, L1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev b60c194f9c5d454f3a79514138592d23de2c890b parent d0c7761
1 file changed, +37 −0
  • internal/fichas/suite_test.go +37 −0

CI passed — run details

diff --git a/internal/fichas/suite_test.go b/internal/fichas/suite_test.go
index bc6ddee..6e0d7d9 100644
--- a/internal/fichas/suite_test.go
+++ b/internal/fichas/suite_test.go
@@ -343,6 +343,43 @@ func TestSuiteFeedCursorReadFailureIsNotAReset(t *testing.T) {
}
}
+// The same for the page read that follows a recognised cursor: a failure
+// there is a 503, never the reset. Only the second events query fails, so
+// the cursor lookup succeeds and the page read is the one that breaks
+// (Fable's review of d0c7761, L1: failing every events query tripped the
+// lookup first and left this path untested).
+//
+// MUTATION-TESTED 2026-11-02, reverted: the page read's error mapped to
+// server.ErrCursorReset → "a failed page read" and "through the server".
+func TestSuiteFeedPageReadFailureIsNotAReset(t *testing.T) {
+ g, a, p := suiteWorld(t)
+ mustCard(t, g, a, map[string]string{FieldName: "Cnoc Teoranta"})
+ _, tip := readFeed(t, p, "", 10)
+ mustCard(t, g, a, map[string]string{FieldName: "Sliabh Teoranta"})
+ failing, seen := false, 0
+ if err := g.Callback().Query().Before("gorm:query").Register("test:fail_page", func(tx *gorm.DB) {
+ if failing && tx.Statement.Table == "events" {
+ seen++
+ if seen == 2 {
+ tx.AddError(errors.New("the disk went away"))
+ }
+ }
+ }); err != nil {
+ t.Fatal(err)
+ }
+ failing = true
+ if f, err := p.Feed(ctx(), tip, 10); err == nil || errors.Is(err, server.ErrCursorReset) {
+ t.Errorf("a failed page read: %+v, %v; want an error that is not the reset", f, err)
+ }
+ if seen < 2 {
+ t.Fatalf("only %d events queries ran, so the page read was never reached", seen)
+ }
+ seen = 0
+ if rec := serve(t, p, "GET", suite.RouteS1+"?cursor="+url.QueryEscape(tip), nil); rec.Code != 503 {
+ t.Errorf("through the server: %d %q, want 503", rec.Code, rec.Body.String())
+ }
+}
+
// S2, every branch of spec §6.3's table.
//
// Revisions are issued 10 apart here (10, 20, 30), so the table can ask