Skip to content

bug: JSON log format breaks on registerValidator due to *http.Request field containing func() type #894

@dom-nie

Description

@dom-nie

Bug Report

Description

When running mev-boost with JSON logging (-json flag), the following error is printed to stderr on every registerValidator call:

Failed to obtain reader, failed to marshal fields to JSON, json: unsupported type: func() (io.ReadCloser, error)

Root Cause

In server/register_validator.go:50-52, the full *http.Request struct is passed as a logrus field:

log.WithFields(logrus.Fields{
    "request": req,
}).Debug("sending the registerValidator request")

*http.Request contains the field GetBody func() (io.ReadCloser, error), which Go's encoding/json cannot marshal. When logrus's JSONFormatter calls json.Marshal() on the log fields, it fails with:

json: unsupported type: func() (io.ReadCloser, error)

Logrus (v1.9.3, used by mev-boost) catches this in entry.write() and prints the error to stderr. The log entry is then silently dropped.

This works fine with the text formatter (which uses fmt.Sprintf("%v", req)), but breaks with -json.

Affected Versions

Confirmed in v1.11 and v1.12 (same code present in both).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions