Skip to content

Commit 0dae95c

Browse files
Add WARNING prefix to fpd type normalization warnings (prebid#912)
1 parent 62ab956 commit 0dae95c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/main/java/org/prebid/server/auction/OrtbTypesResolver.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private JsonNode normalizeNode(JsonNode containerNode, String nodeName,
173173
() -> toCommaSeparatedTextNode(containerObjectNode, fieldName, nodeName, nodePrefix,
174174
warnings)));
175175
} else {
176-
warnings.add(String.format("FDP warning: %s%s field ignored. Expected type is object, but was `%s`.",
176+
warnings.add(String.format("%s%s field ignored. Expected type is object, but was `%s`.",
177177
nodePrefix, nodeName, containerNode.getNodeType().name()));
178178
return null;
179179
}
@@ -252,14 +252,18 @@ private static boolean isTextualArray(ArrayNode arrayNode) {
252252
private void processWarnings(List<String> resolverWarning, List<String> warnings, String containerValue,
253253
String referer, String containerName) {
254254
if (CollectionUtils.isNotEmpty(resolverWarning)) {
255-
warnings.addAll(resolverWarning);
255+
warnings.addAll(updateWithWarningPrefix(resolverWarning));
256256
// log only 1% of cases
257257
if (System.currentTimeMillis() % 100 == 0) {
258-
logger.info(String.format("%s. \n Referer = %s and %s = %s",
258+
logger.info(String.format("WARNINGS: %s. \n Referer = %s and %s = %s",
259259
String.join("\n", resolverWarning),
260260
StringUtils.isNotBlank(referer) ? referer : UNKNOWN_REFERER,
261261
containerName, containerValue));
262262
}
263263
}
264264
}
265+
266+
private List<String> updateWithWarningPrefix(List<String> resolverWarning) {
267+
return resolverWarning.stream().map(warning -> "WARNING: " + warning).collect(Collectors.toList());
268+
}
265269
}

src/test/java/org/prebid/server/auction/OrtbTypesResolverTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ public void normalizeTargetingShouldConvertArrayToFirstElementFieldForUserAndWri
4040
// then
4141
assertThat(inputParam).isEqualTo(mapper.createObjectNode().set("user",
4242
mapper.createObjectNode().put("gender", "male")));
43-
assertThat(errors).containsOnly("Incorrect type for first party data field targeting.user.gender, expected is"
44-
+ " string, but was an array of strings. Converted to string by taking first element of array.");
43+
assertThat(errors).containsOnly("WARNING: Incorrect type for first party data field targeting.user.gender,"
44+
+ " expected is string, but was an array of strings. Converted to string by taking first element "
45+
+ "of array.");
4546
}
4647

4748
@Test
@@ -57,8 +58,9 @@ public void normalizeTargetingShouldConvertArrayToCommaSeparatedStringFieldForUs
5758
// then
5859
assertThat(inputParam).isEqualTo(mapper.createObjectNode().set("user",
5960
mapper.createObjectNode().put("keywords", "keyword1,keyword2")));
60-
assertThat(errors).containsOnly("Incorrect type for first party data field targeting.user.keywords, expected is"
61-
+ " string, but was an array of strings. Converted to string by separating values with comma.");
61+
assertThat(errors).containsOnly("WARNING: Incorrect type for first party data field targeting.user.keywords,"
62+
+ " expected is string, but was an array of strings. Converted to string by separating values with"
63+
+ " comma.");
6264
}
6365

6466
@Test
@@ -85,7 +87,7 @@ public void normalizeTargetingToCommaSeparatedTextNodeShouldWriteMessageAndRemov
8587

8688
// then
8789
assertThat(inputParam).isEqualTo(mapper.createObjectNode().set("user", mapper.createObjectNode()));
88-
assertThat(errors).containsOnly("Incorrect type for first party data field targeting.user.keywords,"
90+
assertThat(errors).containsOnly("WARNING: Incorrect type for first party data field targeting.user.keywords,"
8991
+ " expected strings, but was `ARRAY of different types`. Failed to convert to correct type.");
9092
}
9193

@@ -101,7 +103,7 @@ public void normalizeTargetingToFirstElementTextNodeShouldWriteMessageAndRemoveF
101103

102104
// then
103105
assertThat(inputParam).isEqualTo(mapper.createObjectNode().set("user", mapper.createObjectNode()));
104-
assertThat(errors).containsOnly("Incorrect type for first party data field targeting.user.gender,"
106+
assertThat(errors).containsOnly("WARNING: Incorrect type for first party data field targeting.user.gender,"
105107
+ " expected strings, but was `NUMBER`. Failed to convert to correct type.");
106108
}
107109

0 commit comments

Comments
 (0)