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

Stop throwing errors on blank log messages #17058

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sebastien-helbert
Copy link

Description

Blank log messages should not generating errors. When a client sends a blank log message it should be processed like all other messages.

Motivation and Context

Fixes #5793
Related to docker/for-linux#354 and fluent/fluentd-kubernetes-daemonset#243

@CLAassistant
Copy link

CLAassistant commented Oct 24, 2023

CLA assistant check
All committers have signed the CLA.

@sebastien-helbert sebastien-helbert marked this pull request as draft October 24, 2023 10:14
}
} else if (!messageNode.isMissingNode()) {
if (!messageNode.isTextual()) {
throw new IllegalArgumentException(prefix + "has invalid \"message\": " + messageNode.asText());
}
if (StringUtils.isBlank(messageNode.asText())) {
throw new IllegalArgumentException(prefix + "has empty mandatory \"message\" field.");
if (message == null) {

Choose a reason for hiding this comment

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

Should this not be if (messageNode.asText() == null)? And, can it be null at all now we know messageNode is textual?

if (!shortMessageNode.isMissingNode()) {
if (!shortMessageNode.isTextual()) {
throw new IllegalArgumentException(prefix + "has invalid \"short_message\": " + shortMessageNode.asText());
}
if (StringUtils.isBlank(shortMessageNode.asText()) && StringUtils.isBlank(messageNode.asText())) {
throw new IllegalArgumentException(prefix + "has empty mandatory \"short_message\" field.");
String shortMessage = shortMessageNode.asText();

Choose a reason for hiding this comment

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

This is the same as message, isn't it? And, can it be null now we know that shortMessageNode is textual?

@@ -255,19 +255,21 @@ private void validateGELFMessage(JsonNode jsonNode, UUID id, ResolvableInetSocke

final JsonNode shortMessageNode = jsonNode.path("short_message");
final JsonNode messageNode = jsonNode.path("message");
String message = shortMessageNode.asText();

Choose a reason for hiding this comment

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

This line can be removed, as far as I can see.

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.

GELF message has empty mandatory "short_message" field.
3 participants