Skip to content

Conversation

AntoxaAntoxic
Copy link
Collaborator

🔧 Type of changes

  • new bid adapter
  • bid adapter update
  • new feature
  • new analytics adapter
  • new module
  • module update
  • bugfix
  • documentation
  • configuration
  • dependency update
  • tech debt (test coverage, refactorings, etc.)

✨ What's the context?

What's the context for the changes?

🧠 Rationale behind the change

Why did you choose to make these changes? Were there any trade-offs you had to consider?

🔎 New Bid Adapter Checklist

  • verify email contact works
  • NO fully dynamic hostnames
  • geographic host parameters are NOT required
  • direct use of HTTP is prohibited - implement an existing Bidder interface that will do all the job
  • if the ORTB is just forwarded to the endpoint, use the generic adapter - define the new adapter as the alias of the generic adapter
  • cover an adapter configuration with an integration test

🧪 Test plan

How do you know the changes are safe to ship to production?

🏎 Quality check

  • Are your changes following our code style guidelines?
  • Are there any breaking changes in your code?
  • Does your test coverage exceed 90%?
  • Are there any erroneous console logs, debuggers or leftover code in your changes?

@osulzhenko osulzhenko requested a review from CTMBNara September 15, 2025 09:03
Comment on lines 267 to 296
private Map<String, String> truncateKeys(Map<String, String> keyValues,
Map<String, List<ExtBidderError>> bidWarnings) {

if (truncateAttrChars > 0) {
final List<String> truncatedKeys = new ArrayList<>();
final Map<String, String> keys = keyValues.entrySet().stream().collect(Collectors.toMap(
keyValue -> truncateKey(keyValue.getKey(), truncatedKeys),
Map.Entry::getValue,
(key1, key2) -> key1));

if (!truncatedKeys.isEmpty()) {
final String errorMessage = "The following keys have been truncated: %s"
.formatted(String.join(", ", truncatedKeys));
bidWarnings.computeIfAbsent("targeting", ignored -> new ArrayList<>())
.add(ExtBidderError.of(BidderError.Type.bad_input.getCode(), errorMessage));
}

return keys;
}

return keyValues;
}

private String truncateKey(String key) {
return key.length() > truncateAttrChars
? key.substring(0, truncateAttrChars)
: key;
private String truncateKey(String key, List<String> truncatedKeys) {
if (key.length() > truncateAttrChars) {
truncatedKeys.add(key);
return key.substring(0, truncateAttrChars);
}

return key;
Copy link
Collaborator

Choose a reason for hiding this comment

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

    private Map<String, String> truncateKeys(Map<String, String> keyValues,
                                             Map<String, List<ExtBidderError>> bidWarnings) {

        if (truncateAttrChars <= 0) {
            return keyValues;
        }

        final Map<String, String> keys = new HashMap<>();
        final Set<String> truncatedKeys = new HashSet<>();
        for (Map.Entry<String, String> entry : keyValues.entrySet()) {
            final String key = entry.getKey();
            final String truncatedKey = truncateKey(key);
            keys.putIfAbsent(truncatedKey, entry.getValue());

            if (truncatedKey.length() != key.length()) {
                truncatedKeys.add(truncatedKey);
            }
        }

        if (!truncatedKeys.isEmpty()) {
            final String errorMessage = "The following keys have been truncated: %s"
                    .formatted(String.join(", ", truncatedKeys));
            bidWarnings.computeIfAbsent("targeting", ignored -> new ArrayList<>())
                    .add(ExtBidderError.of(BidderError.Type.bad_input.getCode(), errorMessage));
        }

        return keys;
    }

    private String truncateKey(String key) {
        return key.length() > truncateAttrChars
                ? key.substring(0, truncateAttrChars)
                : key;
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe it should be truncatedKeys.add(key); instead of truncatedKeys.add(truncatedKey); in order to log the original key name

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