Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"logbook.write.max-body-size" not working when creating own BodyFilter that includes defaultValue() #1202

Closed
kosi2801 opened this issue Oct 21, 2021 · 3 comments
Labels

Comments

@kosi2801
Copy link

Description

With using Spring autoconfiguration when a custom BodyFilter is created and the BodyFilters.defaultValue() is used in it, the configuration property "logbook.write.max-body-size" is not working anymore.
This is somewhat unexpected, as there is no indication that the BodyFilters.truncate() is not a default filter.
By reading the documentation it would be assumed that the truncation is always possible (ie. part of the defaultValue() filters).

Expected Behavior

When a custom @Bean BodyFilter bodyFilter() is created and the BodyFilters.defaultValue() is part of the filters, the truncation functionality is applied.

Actual Behavior

No truncation of the body content configured by the "logbook.write.max-body-size" property is applied.

Possible Fix

No exact fix, but as a workaround I had to use:

@Autowired
LogbookAutoConfiguration autoConfiguration;

@Bean
public BodyFilter bodyFilter() {
    return merge(
            autoConfiguration.bodyFilter(), 
            replaceJsonStringProperty(singleton("secret"), "XXX"));
}

Steps to Reproduce

  1. Create SpringBoot app, create dummy endpoint
  2. Create custom @bean BodyFilter bodyFilter like in the documentation example
@Bean
public BodyFilter bodyFilter() {
    return merge(
            defaultValue(), 
            replaceJsonStringProperty(singleton("secret"), "XXX"));
}
  1. configure "logbook.write.max-body-size = 10"
  2. send request to dummy endpoint with larger body content

Context

I was trying to add custom filtering to the existing filters, suddenly the logfiles were swamped by large body logs.

Your Environment

  • Version used: 2.14.0
  • SpringBoot Version: 2.0.3.RELEASE
  • Java Version: 1.8
@kosi2801 kosi2801 added the Bug label Oct 21, 2021
@github-actions
Copy link
Contributor

In order to prioritize the support for Logbook, we would like to check whether the old issues are still relevant.
This issue has not been updated for over a year.

  • Please check if it is still relevant in latest version of the Logbook.
  • If so, please add a descriptive comment to keep the issue open.
  • Otherwise, the issue will automatically be closed after a week.

@github-actions github-actions bot added the stale label Jul 14, 2023
@kosi2801
Copy link
Author

This issue is still present. If a better handling is not possible or feasible, maybe a mention in the documentation could indicate that this is an unexpected behavior? eg. at the documentation for "logbook.write.max-body-size" or the @bean Bodyfilter.

@kasmarian
Copy link
Member

This should be covered by #1592 and will be in the next release. Please re-open the issue if it's not fully addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants