KEMBAR78
UserIds : in case the eids are undefined return an empty array by olafbuitelaar · Pull Request #13765 · prebid/Prebid.js · GitHub
Skip to content

Conversation

olafbuitelaar
Copy link
Contributor

@olafbuitelaar olafbuitelaar commented Aug 12, 2025

  • Bugfix

when bidders try to to access(/iterate over) the userIdAsEids but it's undefined, as created by this PR #13535 these adapters could fail by lacking current null check behavior, causing bid-requests to be not constructed

@Copilot Copilot AI review requested due to automatic review settings August 12, 2025 18:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a potential bug where bidders accessing userIdAsEids could encounter undefined values, which may cause failures when iterating over the property. The change ensures that userIdAsEids always returns an array, preventing runtime errors in bidder adapters.

  • Adds null coalescing operator to return empty array when eids is undefined
  • Maintains backward compatibility while preventing iteration errors

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@ChrisHuie ChrisHuie changed the title in case the eids are undefined return an empty array UserIds : in case the eids are undefined return an empty array Aug 13, 2025
@ChrisHuie ChrisHuie self-requested a review August 13, 2025 13:31
@ChrisHuie ChrisHuie self-assigned this Aug 13, 2025
@patmmccann
Copy link
Collaborator

Whats an example of this failing?

@olafbuitelaar
Copy link
Contributor Author

olafbuitelaar commented Aug 13, 2025

in this particular case it was ozone, when userIdAsEids are undefined, the iteration in findAllUserIdsFromEids https://github.com/prebid/Prebid.js/blob/master/modules/ozoneBidAdapter.js#L682 fails because they only check if the bid-request object has a property userIdAsEids (which was likely the old behavior that this would only be set if their were user-ids), but don't check if the property has actually a value/is iterable in this if; https://github.com/prebid/Prebid.js/blob/master/modules/ozoneBidAdapter.js#L677
as this function is called while constructing bid-request, the bidder errors out, and is not able to perform the bid-requests.
But i wouldn't be surprised if more bidders or consumers of the userId module would follow a similar access pattern. hence the fallback to an empty array. of course it would be good if the bid adapter it self would also check if it can iterate over the collection.

Screenshot 2025-08-12 180643 Screenshot 2025-08-12 175118

@patmmccann patmmccann merged commit c321bea into prebid:master Aug 13, 2025
20 checks passed
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.

3 participants