Skip to content

Commit

Permalink
Hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
VeryExtraordinaryUsername committed Nov 27, 2023
1 parent 5b94381 commit f14509d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/main/java/org/prebid/server/auction/BidResponseCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@

public class BidResponseCreator {

/**
* Default prefix for targeting keys.
* Used in cases, when correspond value is missing in account auction configuration or bid request ext.
*/
private static final String DEFAULT_KEY_PREFIX = "hb";
private static final String CACHE = "cache";
private static final String PREBID_EXT = "prebid";
private static final Integer DEFAULT_BID_LIMIT_MIN = 1;
Expand Down Expand Up @@ -1664,8 +1659,8 @@ private TargetingKeywordsCreator createKeywordsCreator(ExtRequestTargeting targe
JsonNode priceGranularity,
BidRequest bidRequest,
Account account) {
int resolvedTruncateAttrChars = resolveTruncateAttrChars(targeting, account);
String resolveKeyPrefix = resolveKeyPrefix(bidRequest, account, resolvedTruncateAttrChars);
final int resolvedTruncateAttrChars = resolveTruncateAttrChars(targeting, account);
final String resolveKeyPrefix = resolveKeyPrefix(bidRequest, account, resolvedTruncateAttrChars);
return TargetingKeywordsCreator.create(
parsePriceGranularity(priceGranularity),
BooleanUtils.toBoolean(targeting.getIncludewinners()),
Expand Down Expand Up @@ -1694,6 +1689,12 @@ private int resolveTruncateAttrChars(ExtRequestTargeting targeting, Account acco
truncateAttrChars);
}

/**
* Returns targeting key prefix.
* Default prefix for targeting keys used in cases,
* when correspond value is missing in account auction configuration or bid request ext,
* or may compose keys longer than 'settings.targeting.truncate-attr-chars' value.
*/
private static String resolveKeyPrefix(BidRequest bidRequest, Account account, int truncateAttrChars) {
final String prefix = Optional.of(bidRequest)
.map(BidRequest::getExt)
Expand All @@ -1705,7 +1706,7 @@ private static String resolveKeyPrefix(BidRequest bidRequest, Account account, i
.map(AccountAuctionConfig::getTargeting)
.map(AccountTargetingConfig::getPrefix)
.orElse(null));
return StringUtils.isNotEmpty(prefix) && prefix.length() + 11 < truncateAttrChars ? prefix : DEFAULT_KEY_PREFIX;
return StringUtils.isNotEmpty(prefix) && prefix.length() + 11 < truncateAttrChars ? prefix : "hb";
}

private static Integer truncateAttrCharsOrNull(Integer value) {
Expand Down

0 comments on commit f14509d

Please sign in to comment.