Skip to content

Request logging silently discarded for non-JSON/form-encoded entity types #1322

@mhagnumdw

Description

@mhagnumdw

Description

When calling MergeRequestApi.acceptMergeRequest(projectId, mrIid), the HTTP request line and headers are not logged, even though the response is logged normally.

Root cause

In MaskingLoggingFilter.aroundWriteTo(), there's a conditional check that only logs when the media type is application/json or application/x-www-form-urlencoded:

if (mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE)
|| mediaType.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) {
log(stream.getStringBuilder(MessageUtils.getCharset(mediaType)));
}

For text/plain the request line and headers accumulated in the StringBuilder are discarded.

Expected Log (should show PUT request)

11:57:55,027 INFO [train-processor-1] 1 - Sending client request on thread train-processor-1
1 > PUT http://localhost:8929/api/v4/projects/1/merge_requests/2/merge
1 > Accept: application/json
1 > Content-Type: text/plain
1 > PRIVATE-TOKEN: ********

11:57:55,188 INFO [train-processor-1] 1 - Received server response on thread train-processor-1
1 < 422
1 < Cache-Control: no-cache
1 < Content-Length: 37
1 < Content-Type: application/json
...

Current Behavior (request missing)

Only the response is logged; the request line and headers are lost.

Question

Why does the if condition in aroundWriteTo() restrict logging only to JSON and form-urlencoded? Without this check, the request logs appear correctly. I've already run some tests without that if statement and everything seems okay.

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