From f9b79909802dc83bf9e59b8509c663baeb86742a Mon Sep 17 00:00:00 2001 From: Philippe Boneff Date: Fri, 18 Sep 2026 14:03:43 +0000 Subject: [PATCH] cmd/mtc/mirror: respond with 200 OK when nextEntry >= uploadEnd Per C2SP tlog-mirror, an add-entries request completing up to upload_end must receive a 200 OK status code even if upload_end < pendingSize. --- cmd/mtc/mirror/internal/handler/handler.go | 2 +- cmd/mtc/mirror/internal/handler/handler_test.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/mtc/mirror/internal/handler/handler.go b/cmd/mtc/mirror/internal/handler/handler.go index 349e5f858..b3e5ce23f 100644 --- a/cmd/mtc/mirror/internal/handler/handler.go +++ b/cmd/mtc/mirror/internal/handler/handler.go @@ -121,7 +121,7 @@ func addEntries(m *MirrorMux) http.HandlerFunc { http.Error(w, "Failed to add entries", http.StatusInternalServerError) return - case nextEntry == pendingSize: + case nextEntry >= req.uploadEnd: // SPEC: If next_entry == upload_end, and no cosignatures are provided by the mirror, // the mirror MUST respond with a "200 OK" status code and an empty response body. // If next_entry == upload_end, and cosignatures are provided by the mirror, diff --git a/cmd/mtc/mirror/internal/handler/handler_test.go b/cmd/mtc/mirror/internal/handler/handler_test.go index a6560acb9..33fa65a0a 100644 --- a/cmd/mtc/mirror/internal/handler/handler_test.go +++ b/cmd/mtc/mirror/internal/handler/handler_test.go @@ -209,6 +209,16 @@ func TestAddEntries_StatusCodes(t *testing.T) { }, wantStatus: http.StatusOK, wantBody: testCosig, + }, { + name: "200 ok (uploadEnd reached before pendingSize)", + origin: testOrigin, + mockTarget: &mockTarget{ + addEntriesFunc: func(ctx context.Context, uploadStart, uploadEnd uint64, ticket []byte, next func() (*tessera.MirrorPackage, error)) (uint64, uint64, []byte, []byte, error) { + return testUploadEnd, testPendingSize, []byte(testNewTicket), nil, nil + }, + }, + wantStatus: http.StatusOK, + wantBody: "", }, { name: "202 partial upload", origin: testOrigin,