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

Flip the default should throw behavior for HttpJsonMessageWithFaultingPayload #1176

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

gregschohn
Copy link
Collaborator

Flip the default should throw behavior for HttpJsonMessageWithFaultingPayload to opt-in rather than opt-out.

HttpJsonMessageWithFaultingPayload throws by default - so it could be run even if it wasn't within a transform - like from within a LoggingHandler, which is what I was observing when I added some more logging. The worst part was that it created other errors which then caused the message to be processed in a very different way.

Description

  • Category Bug fix
  • Why these changes are required? When logging levels go up, the system behaves as if logging weren't enabled!
  • What is the old behavior before changes and new behavior after changes?

Issues Resolved

https://opensearch.atlassian.net/browse/MIGRATIONS-2242

Testing

gradle/cicd

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@gregschohn gregschohn force-pushed the SaferPayloadFaults branch 2 times, most recently from 5c3cb8a to 1e1847d Compare December 4, 2024 04:11
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.87%. Comparing base (2fc4f88) to head (9c69dd8).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1176      +/-   ##
============================================
- Coverage     80.95%   80.87%   -0.08%     
+ Complexity     2996     2995       -1     
============================================
  Files           407      407              
  Lines         15231    15237       +6     
  Branches       1023     1023              
============================================
- Hits          12330    12323       -7     
- Misses         2272     2286      +14     
+ Partials        629      628       -1     
Flag Coverage Δ
unittests 80.87% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gregschohn gregschohn marked this pull request as ready for review December 4, 2024 04:42
// ContentType not text if specified and has a value with / and that value does not start with text/
return Optional.ofNullable(capturedHttpJsonMessage.headers().insensitiveGet(HttpHeaderNames.CONTENT_TYPE.toString()))
.map(s -> s.stream()
.filter(v -> v.contains("/"))
.filter(v -> !v.startsWith("text/"))
.filter(cnotentTypeFilter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix spelling

@@ -93,7 +95,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
}
}
} catch (JacksonException e) {
log.atInfo().setCause(e).setMessage("Error parsing json body. " +
log.atLevel(hasRequestContentTypeMatching(capturedHttpJsonMessage, v -> v.startsWith("application/json"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment in the code on why we're doing this could be helpful

Copy link
Member

@AndreKurait AndreKurait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the spelling issue and this change looks good

…gPayload to opt-in rather than opt-out.

HttpJsonMessageWithFaultingPayload throws by default - so it could be run even if it wasn't within a transform - like from within a LoggingHandler, which is what I was observing when I added some more logging.  The worst part was that it created other errors which then caused the message to be processed in a very different way.

Signed-off-by: Greg Schohn <[email protected]>
@gregschohn gregschohn merged commit 1df1642 into opensearch-project:main Dec 10, 2024
18 of 20 checks passed
@gregschohn gregschohn deleted the SaferPayloadFaults branch December 10, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants