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

BidRequest updated by ProcessedAuction hook is getting overridden by requestwrapper utility #2986

Closed
pm-nikhil-vaidya opened this issue Jul 28, 2023 · 4 comments
Assignees
Labels
needs docs Docs are required for this PR or Issue PBS-Go

Comments

@pm-nikhil-vaidya
Copy link
Contributor

Background
With the introduction of module, hooks have the capabilities to modify the bid request but these modifications are overridden by request wrapper utilities

Solution 1
Pass bid request wrapper in the hook payload instead of only bid request object

Solution 2
Create a request wrapper with new bid request after each hook execution

@AlexBVolcy
Copy link
Contributor

After looking into this I believe that it's true the updates the changeset is making to the bid request is being overwritten by the request wrapper.

Within auction.go/parseRequest, the changeset is being applied to the base request through this call hookExecutor.ExecuteRawAuctionStage(). The base request is then unmarshalled into the request wrapper.

However, before the request wrapper is returned, the wrapper itself is updated through mergeBidderParams, setFieldsImplicitly, setDefaults before parseRequest validates and returns. So I think it’s within these functions where the overwrite is occurring

@hhhjort
Copy link
Collaborator

hhhjort commented Aug 1, 2023

I think there is some confusion here. In enndpoints/openrtb2/auction.go:parseRequest, there is no request wrapper, the modules are operating on raw JSON. We get to a request object and a request wrapper that modules can use in exchange/exchange.go. For example: r.HookExecutor.ExecuteProcessedAuctionStage(r.BidRequestWrapper).

Here we are pushing into the hook executor the full bidwrapper. But the payload to the modules is just a plain openrtb2 bid request. The modules then create mutators for the bid request that can be executed to modify the request appropriately. Modifying the exts in the request wrapper requires executing functions rather than just setting values. I am not familiar enough with the mutator system here to know if this can be handled by the mutator system, or if it needs mutators that only set values in structs. If the mutators can handle the wrappers, it would likely take quite a bit of work, and be a breaking change to the module API to push the wrapper into the payload. However the alternative of rebuilding the request wrapper after each module execution would be a significant drain on computing resources.

@pm-nikhil-vaidya pm-nikhil-vaidya changed the title BidRequest updated by hooks are getting overridden by request wrapper utility BidRequest updated by ProcessedAuctionStage hook are getting overridden by request wrapper utility Aug 19, 2023
@pm-nikhil-vaidya pm-nikhil-vaidya changed the title BidRequest updated by ProcessedAuctionStage hook are getting overridden by request wrapper utility BidRequest updated by ProcessedAuction hook are getting overridden by requestwrapper utility Aug 21, 2023
@pm-nikhil-vaidya pm-nikhil-vaidya changed the title BidRequest updated by ProcessedAuction hook are getting overridden by requestwrapper utility BidRequest updated by ProcessedAuction hook is getting overridden by requestwrapper utility Aug 21, 2023
@bretg
Copy link
Contributor

bretg commented Oct 20, 2023

This is a documentation issue. @bsardo has offered to update the module developer doc. Thanks!

@bretg bretg added the needs docs Docs are required for this PR or Issue label Oct 20, 2023
@bsardo
Copy link
Collaborator

bsardo commented Feb 23, 2024

Closing as there aren't any docs updates needed. The docs don't specify the types of each hook's payload and can be easily determined from looking at the code.
I also confirmed that the request wrapper is part of the payload at both the ProcessedAuction and BidderRequest hook stages.

@bsardo bsardo closed this as completed Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs docs Docs are required for this PR or Issue PBS-Go
Projects
Status: Done
Development

No branches or pull requests

6 participants