Skip to content

Log error at error level for 500 errors#894

Open
cmurphy wants to merge 1 commit into
transparency-dev:mainfrom
cmurphy:error-logging
Open

Log error at error level for 500 errors#894
cmurphy wants to merge 1 commit into
transparency-dev:mainfrom
cmurphy:error-logging

Conversation

@cmurphy

@cmurphy cmurphy commented Jul 7, 2026

Copy link
Copy Markdown

An HTTP 500 should be logged as an error since an operator likely needs
to take action to fix the problem.

@cmurphy cmurphy requested a review from a team as a code owner July 7, 2026 21:09
@cmurphy cmurphy requested review from mhutchinson and removed request for a team July 7, 2026 21:09
@cmurphy

cmurphy commented Jul 7, 2026

Copy link
Copy Markdown
Author

See also sigstore/fulcio#2393

@AlCutter AlCutter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Most of these seem like a good call - they should be rare but you'd want to know about them.

Comment thread internal/ct/handlers.go Outdated
err = marshalAndWriteAddChainResponse(sct, w)
if err != nil {
// reason is logged and http status is already set
slog.ErrorContext(ctx, "Failed to write response", slog.Any("error", err))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd be tempted to remove this one. All(?) the others are rare and indicative of something local going wrong (either local infra, or bugs).

This one, I suspect, is almost always just going to be a badly behaved client closing their socket early and so likely not actionable.

@phbnf

phbnf commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

I think that error messages should already propagate to warnings on line 249. Is there a scenario in which they wouldn't?

@cmurphy

cmurphy commented Jul 8, 2026

Copy link
Copy Markdown
Author

I think that error messages should already propagate to warnings on line 249. Is there a scenario in which they wouldn't?

We are seeing 500 errors frequently with no logs at any level to indicate what's going on.

@cmurphy

cmurphy commented Jul 8, 2026

Copy link
Copy Markdown
Author

We are seeing 500 errors frequently with no logs at any level to indicate what's going on.

When I searched explicitly for "handler error" at the warning level I finally found it, it had been lost in a sea of other warnings. Since this caused a 500 I think this should be logged at the Error level rather than Warning so that it would be easier to find.

An HTTP 500 should be logged as an error since an operator likely needs
to take action to fix the problem.
@cmurphy cmurphy changed the title Add error logging when a server error is returned Log error at error level for 500 errors Jul 8, 2026
@cmurphy

cmurphy commented Jul 8, 2026

Copy link
Copy Markdown
Author

I've changed this to not log within the individual handler but to log at an error level when the handler returns.

@phbnf phbnf mentioned this pull request Jul 10, 2026
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