Skip to content

Strategy 'BodyOnlyIfStatusAtLeastStrategy' does not log response attributes #2115

@MrShruikhan

Description

@MrShruikhan

Description

As mentioned in #2024 there was a bug if you use the BodyOnlyIfStatusAtLeastStrategy and AttributeExtractors. This is also true to response attributes if the response status is less than the minimum status.

Expected Behavior

withoutBody() should only remove the body from the response.

Actual Behavior

Attributes are not logged for response.

Possible Fix

Give the treatment that was given to FilteredHttpRequest also to FilteredHttpResponse

Steps to Reproduce

  1. log with strategy BodyOnlyIfStatusAtLeastStrategy and status=400
  2. create ResponseExtractor:
@Component
public class CustomResponseExtractor implements AttributeExtractor

@Override
public HttpAttributes extract(HttpRequest request, HttpResponse response) {
  return new HttpAttributes(Map.of("customAttribute", "someValue"));
}
  1. use CustomResponseExtractor in application.yml
logbook:
  strategy: body-only-if-status-at-least
  minimum-status: 400
  attribute-extractors:
    - type: CustomResponseExtractor

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions