Skip to content

Conditionally Display Message and Header in MessageHandlingException #9416

@gc-1111

Description

@gc-1111

I would like to force spring integration not to display certain messages/headers, because they may contain PII.

Tell us how it should works
If message header hideMessageDataInException=true

Exception Message should have no "FailedMessage" Section:
org.springframework.messaging.MessageHandlingException: error occurred during processing message in 'MethodInvokingMessageProcessor' [org.springframework.integration.handler.MethodInvokingMessageProcessor@5494e631]

Note: hideMessageDataInException can default to false to maintain existing behavior.

Explain the difference from current behavior
Currently, the exception always includes failedMessage section of error message. We have no way to block failedMessage from appearing, even if the message include PII. We would like to log the exception, but it has PII in it.

org.springframework.messaging.MessageHandlingException: error occurred during processing message in 'MethodInvokingMessageProcessor' [org.springframework.integration.handler.MethodInvokingMessageProcessor@5494e631], failedMessage=GenericMessage [payload=hasPII, headers={hasPII}]

How has this issue affected you?
We are not able to hide PII in the logs.

What are you trying to accomplish?
We would like to log our error message, but not include the failed message in the logs. I get why often it is nice to have the failedMessage in the logs, but there is no way to turn that off.

What other alternatives have you considered?
We could make a custom logger, that check each logged string for failedMessage=GenericMessage... and remove that section of the log message.

Are you aware of any workarounds?
Not really.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions