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

Return 'none' body filter if list of to-be-filtered JSON field-names is empty #2007

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

skjolber
Copy link
Contributor

@skjolber skjolber commented Jan 12, 2025

The Spring auto-configuration adds a body filter JacksonJsonFieldBodyFilter for JSON payloads without checking that there is actually some filtering to be performed.

Description

The LogbookProperties Obfuscate class jsonBodyFields field defaults to empty.

Add empty check, if so return noop filter.

Motivation and Context

Avoid unnecessary parse of JSON payloads.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@skjolber
Copy link
Contributor Author

skjolber commented Jan 12, 2025

Wiring of default empty obfuscate filters could be avoided entirely using a custom Conditional.

@kasmarian
Copy link
Member

Thank you for the PR! I now wonder if the check for fields!=empty() should be done in JacksonJsonFieldBodyFilter itself. On the other hand, if after this change, people add it manually, they'd probably always have some fields to obfuscate.

@kasmarian
Copy link
Member

ah, wait. We can't merge it as they commits are not signed. @skjolber would you be able forcepush only signed commits?

@skjolber skjolber force-pushed the emptyObfuscateJsonBodyFields branch from 4a547b1 to 5a6fb9d Compare January 13, 2025 16:29
@skjolber
Copy link
Contributor Author

@kasmarian better? First time signing commits.

@kasmarian
Copy link
Member

Yes, looks good now, thank you!

@skjolber
Copy link
Contributor Author

FYI this solves #1882 (did not see the issue until just now).

@kasmarian
Copy link
Member

@msdousti could you re-approve?

@msdousti msdousti merged commit e8515c1 into zalando:main Jan 14, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bug fixes and patches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants