Skip to content

cmd/mtc/mirror/handler.go improve SPEC references, and remove erroneous referrence - #1200

Open
phbnf wants to merge 2 commits into
transparency-dev:mainfrom
phbnf:200OK
Open

phbnf wants to merge 2 commits into
transparency-dev:mainfrom
phbnf:200OK

Conversation

@phbnf

@phbnf phbnf commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Towards #945.

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.

Courtesy of Gemini, and it looks legit to me.

@phbnf
phbnf requested review from AlCutter and roger2hk September 24, 2026 13:08
@phbnf
phbnf marked this pull request as ready for review September 24, 2026 13:09
@phbnf
phbnf requested a review from a team as a code owner September 24, 2026 13:09

@roger2hk roger2hk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Gemini reads the spec comment in the code which is misleading.

Comment on lines +213 to +221
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: "",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case expects 200 OK with an empty body, which the tlog-mirror spec doesn't allow. A successful add-entries response "MUST be … a sequence of one or more note signature lines", and "the mirror MUST persist the new checkpoint before responding".

Also, the MirrorTarget.AddEntries can't return this combination (nextEntry == uploadEnd, pendingSize != uploadEnd, no cosigs, no error). It takes the pending checkpoint from the ticket and returns ErrConflict unless that checkpoint's size equals uploadEnd.

Comment on lines 125 to 128

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec here does not align with the tlog-mirror specification which doesn't say returning an empty response body in 200 OK.

The implementation here is correct to return 200 OK with the cosignatures.

phbnf added 2 commits October 16, 2026 16:34
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.
…rror spec

Audit all SPEC comments in the mirror HTTP handler to include exact URLs
and quotes from c2sp.org/tlog-mirror and c2sp.org/tlog-cosignature.

Specifically, fix a misleading SPEC comment that suggested a 200 OK response
on add-entries could return an empty response body without cosignatures;
in c2sp.org/tlog-mirror, a 200 Success response on add-entries must always
return the mirror's cosignatures over the newly published checkpoint. Also
remove the corresponding test expecting an empty body on 200 OK.
@phbnf phbnf changed the title cmd/mtc/mirror: respond with 200 OK when nextEntry >= uploadEnd cmd/mtc/mirror/handler.go improve SPEC references, and remove erroneous referrence Oct 16, 2026
@phbnf

phbnf commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Well spotted @roger2hk!

I have therefore repurposed this PR to remove the erroneous spec reference, and to better format all other references in this file.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants