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

Fix: Inject default DSA before auction request is rebuilt #3639

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,19 @@ func (e *exchange) HoldAuction(ctx context.Context, r *AuctionRequest, debugLog

// Make our best guess if GDPR applies
gdprDefaultValue := e.parseGDPRDefaultValue(r.BidRequestWrapper)
gdprSignal, err := getGDPR(r.BidRequestWrapper)
if err != nil {
return nil, err
}
channelEnabled := r.TCF2Config.ChannelEnabled(channelTypeMap[r.LegacyLabels.RType])
Copy link

@scr-oath scr-oath May 31, 2024

Choose a reason for hiding this comment

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

This causes panic for the /openrtb2/video endpoint now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please share a stack trace?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, nevermind, A pull request to fix it is better,. :)

gdprEnforced := enforceGDPR(gdprSignal, gdprDefaultValue, channelEnabled)
dsaWriter := dsa.Writer{
Config: r.Account.Privacy.DSA,
GDPRInScope: gdprEnforced,
}
if err := dsaWriter.Write(r.BidRequestWrapper); err != nil {
return nil, err
}

// rebuild/resync the request in the request wrapper.
if err := r.BidRequestWrapper.RebuildRequest(); err != nil {
Expand All @@ -324,7 +337,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r *AuctionRequest, debugLog
Prebid: *requestExtPrebid,
SChain: requestExt.GetSChain(),
}
bidderRequests, privacyLabels, errs := e.requestSplitter.cleanOpenRTBRequests(ctx, *r, requestExtLegacy, gdprDefaultValue, bidAdjustmentFactors)
bidderRequests, privacyLabels, errs := e.requestSplitter.cleanOpenRTBRequests(ctx, *r, requestExtLegacy, gdprSignal, gdprEnforced, bidAdjustmentFactors)
errs = append(errs, floorErrs...)

mergedBidAdj, err := bidadjustment.Merge(r.BidRequestWrapper, r.Account.BidAdjustments)
Expand Down
23 changes: 3 additions & 20 deletions exchange/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/prebid/openrtb/v20/openrtb2"

"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/dsa"
"github.com/prebid/prebid-server/v2/errortypes"
"github.com/prebid/prebid-server/v2/firstpartydata"
"github.com/prebid/prebid-server/v2/gdpr"
Expand Down Expand Up @@ -60,7 +59,9 @@ type requestSplitter struct {
func (rs *requestSplitter) cleanOpenRTBRequests(ctx context.Context,
auctionReq AuctionRequest,
requestExt *openrtb_ext.ExtRequest,
gdprDefaultValue gdpr.Signal, bidAdjustmentFactors map[string]float64,
gdprSignal gdpr.Signal,
gdprEnforced bool,
bidAdjustmentFactors map[string]float64,
) (allowedBidderRequests []BidderRequest, privacyLabels metrics.PrivacyLabels, errs []error) {
req := auctionReq.BidRequestWrapper
aliases, errs := parseAliases(req.BidRequest)
Expand All @@ -83,24 +84,6 @@ func (rs *requestSplitter) cleanOpenRTBRequests(ctx context.Context,
return
}

gdprSignal, err := getGDPR(req)
if err != nil {
errs = append(errs, err)
}
channelEnabled := auctionReq.TCF2Config.ChannelEnabled(channelTypeMap[auctionReq.LegacyLabels.RType])
gdprEnforced := enforceGDPR(gdprSignal, gdprDefaultValue, channelEnabled)
dsaWriter := dsa.Writer{
Config: auctionReq.Account.Privacy.DSA,
GDPRInScope: gdprEnforced,
}
if err := dsaWriter.Write(req); err != nil {
errs = append(errs, err)
}
if err := req.RebuildRequest(); err != nil {
errs = append(errs, err)
return
}

var allBidderRequests []BidderRequest
var allBidderRequestErrs []error
allBidderRequests, allBidderRequestErrs = getAuctionBidderRequests(auctionReq, requestExt, rs.bidderToSyncerKey, impsByBidder, aliases, rs.hostSChainNode)
Expand Down
Loading
Loading