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

Adnuntius: Return DSA in bid response #3777

Merged
merged 5 commits into from
Sep 18, 2024
Merged

Conversation

mikael-lundin
Copy link
Contributor

This enables DSA for our adapter. it reads the ORTB, see if DSA is applicable and then return the DSA information. we start with advertiser name and move onto more information if needed from our clients.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 5be5c75

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:97:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:107:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:111:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:127:	makeEndpointUrl		89.3%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:176:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:199:	generateRequests	90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:315:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:342:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:352:	getGDPR			85.7%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:377:	generateReturnExt	50.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:409:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:482:	generateBidResponse	88.0%
total:									(statements)		85.6%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 74e9288

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:97:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:107:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:111:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:127:	makeEndpointUrl		89.3%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:176:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:199:	generateRequests	90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:315:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:342:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:352:	getGDPR			85.7%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:377:	generateReturnExt	83.3%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:409:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:482:	generateBidResponse	88.0%
total:									(statements)		87.7%

@bsardo bsardo changed the title Adnuntius Bid Adapter: Pass DSA back to Prebid Adnuntius: Return DSA in bid response Jul 26, 2024
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Error extracting Ext: %s", err.Error()),
}}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add test for this. Not covered
image

@bsardo bsardo self-assigned this Aug 1, 2024
Copy link

github-actions bot commented Aug 7, 2024

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, e3015ac

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:97:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:107:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:111:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:127:	makeEndpointUrl		89.3%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:176:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:199:	generateRequests	90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:315:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:342:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:352:	getGDPR			85.7%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:377:	generateReturnExt	83.3%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:409:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:482:	generateBidResponse	88.0%
total:									(statements)		87.7%

@mikael-lundin
Copy link
Contributor Author

hi, has anyone looked at my comment?

przemkaczmarek
przemkaczmarek previously approved these changes Aug 21, 2024
@bsardo
Copy link
Collaborator

bsardo commented Aug 22, 2024

hi, has anyone looked at my comment?

Hi @mikael-lundin, I don't see any comments from you nor do I see any updates other than merging with master. Please see the two comments from @przemkaczmarek.

I'll give this another look once you've addressed those. Thanks!

@przemkaczmarek przemkaczmarek self-requested a review August 22, 2024 14:32
@mikael-lundin
Copy link
Contributor Author

Strange. :) my question was if I needed to test the error or the function? Because the function should be covered. :)

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, c72dfc0

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:97:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:107:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:111:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:127:	makeEndpointUrl		92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:176:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:199:	generateRequests	92.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:315:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:342:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:352:	getGDPR			92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:377:	generateReturnExt	83.3%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:409:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:482:	generateBidResponse	88.0%
total:									(statements)		89.2%

@przemkaczmarek
Copy link
Collaborator

@mikael-lundin You added a master to this PR. This is incorrect because we cannot track the changes. please undo this comit

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, e813f2d

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:98:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:108:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:112:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:128:	makeEndpointUrl		92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:177:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:200:	generateRequests	92.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:316:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:343:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:353:	getGDPR			92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:378:	generateReturnExt	83.3%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:410:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:483:	generateBidResponse	88.0%
total:									(statements)		89.2%

@mikael-lundin
Copy link
Contributor Author

Sorry about that, should be cleaned up now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It appears you added this test to verify an error occurs during MakeBids when looking for the DSA object in the response, however, this test is actually forcing an error in MakeRequests when looking for the regs.ext.gdpr signal. I think this test is worth keeping; I would just change its name to something like invalid-regs-ext.json or regs-ext-error.json.

I don't think you'll be able to test the new MakeBids regs.ext unmarshal error code paths because that would involve setting regs.ext to something invalid but doing that will cause an error in MakeRequests before the MakeBids logic runs since regs.ext is unmarshaled in both functions and MakeRequests runs first.

},
"expectedMakeRequestsErrors": [
{
"value": "failed to parse URL: [failed to parse Adnuntius endpoint: failed to parse ExtRegs in Adnuntius GDPR check: json: cannot unmarshal string into Go value of type openrtb_ext.ExtRegs]",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this is not new logic but I just want to point out that this error is a little misleading since the error does not appear to be due to parsing a URL or the endpoint but rather due to a failure parsing the ExtRegs while attempting to generate the URL. Perhaps you want to address this in a future PR?

}
}

if requestRegsExt != nil && requestRegsExt.DSA != nil && requestRegsExt.DSA.PubRender != &adRender {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comparison requestRegsExt.DSA.PubRender != &adRender will always be not equal since you're comparing memory addresses and the memory address of requestRegsExt.DSA.PubRender will never be the same as adRender.

I suggest adding another JSON test called check-dsa-pubrender-zero.json and renaming your test check-dsa.json to check-dsa-pubrender-non-zero.json.

Then I think you want to change this conditional to the following so that you are comparing the values instead of the memory addresses:
if requestRegsExt != nil && requestRegsExt.DSA != nil && requestRegsExt.DSA.PubRender != nil && *requestRegsExt.DSA.PubRender != adRender

Also, what happens if regs.ext.dsa.pubrender is nil or if regs.ext.dsa.pubrender is 0? You don't want the dsa object included in the bid response in these cases?

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, a647892

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:98:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:108:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:112:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:128:	makeEndpointUrl		92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:177:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:200:	generateRequests	92.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:316:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:343:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:353:	getGDPR			92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:378:	generateReturnExt	83.3%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:410:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:483:	generateBidResponse	88.0%
total:									(statements)		89.2%

adapters/adnuntius/adnuntius.go Show resolved Hide resolved
}
}

if requestRegsExt != nil && requestRegsExt.DSA != nil && &ad.Advertiser != nil && &ad.Advertiser.LegalName != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like you're now trying to detect presence of LegalName as part of this conditional, in which case either of these would be considered a preferred approach:

  1. if you don't care to differentiate between presence and an empty string meaning you want to create a DSA if legal name doesn't exist as well as when legal name has been provided but is an empty string, keep LegalName as type string and change &ad.Advertiser.LegalName != nil to ad.Advertiser.LegalName != ""
  2. if you do care to differentiate between presence and an empty string where you want to create a DSA only if legal name exists including the empty string case, change LegalName to type *string and change &ad.Advertiser.LegalName != nil to ad.Advertiser.LegalName != nil

}
}

if requestRegsExt != nil && requestRegsExt.DSA != nil && &ad.Advertiser != nil && &ad.Advertiser.LegalName != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn't need to check if ad.Advertiser is present via && &ad.Advertiser != nil since Advertiser will always exist on the Ad struct since it isn't defined as a pointer:

type Ad struct {
	...
	DestinationUrls map[string]string
	Advertiser      adnAdvertiser
}

In the case where it isn't defined in the response from your server, when it is mapped to your structs, the Advertiser field will exist as a zero-value struct.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove copy from the name of this file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since you've changed the behavior that determines whether to create a DSA from being dependent on the value of pubrender to being dependent on the value of Advertiser.LegalName, I don't think these check-dsa-pubrender tests are serving much of a purpose. Instead you should probably add the following tests:

  1. ad.advertiser is not provided
  2. ad.advertiser is provided with legal name missing
  3. ad.advertiser is provided with legal name as empty string
  4. ad.advertiser is provided with legal name not empty

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please see above comment regarding tests. Your code isn't doing anything with pubrender anymore other than hardcoding the AdRender field to zero. Consider getting rid of the multiple pubrender tests and instead adding the test cases I outlined above so that you're exercising the various advertiser name and legal name scenarios.

Copy link

github-actions bot commented Sep 5, 2024

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 4d7e45d

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:98:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:108:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:112:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:128:	makeEndpointUrl		92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:177:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:200:	generateRequests	92.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:316:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:343:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:353:	getGDPR			92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:378:	generateReturnExt	86.7%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:414:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:487:	generateBidResponse	88.0%
total:									(statements)		89.4%

@mikael-lundin
Copy link
Contributor Author

Hi has anyone had time to look at my changes?

Comment on lines 408 to 410
} else {
return nil, nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: you can get rid of the else and just have return nil, nil

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please see above comment regarding tests. Your code isn't doing anything with pubrender anymore other than hardcoding the AdRender field to zero. Consider getting rid of the multiple pubrender tests and instead adding the test cases I outlined above so that you're exercising the various advertiser name and legal name scenarios.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 38120a5

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:98:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:108:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:112:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:128:	makeEndpointUrl		92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:177:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:200:	generateRequests	92.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:316:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:343:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:353:	getGDPR			92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:378:	generateReturnExt	86.7%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:412:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:485:	generateBidResponse	88.0%
total:									(statements)		89.4%

@mikael-lundin
Copy link
Contributor Author

Hi, so now I added some tests for advertiser instead, to check for the three things that can happen in our ad server. Thank you all for your guidance and great help. :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: remove copy from the file name renaming it to check-dsa-advertiser-legalName.json

@@ -387,7 +387,7 @@ func generateReturnExt(ad Ad, request *openrtb2.BidRequest) (json.RawMessage, er
}
}

if requestRegsExt != nil && requestRegsExt.DSA != nil {
if ad.Advertiser.Name != "" && requestRegsExt != nil && requestRegsExt.DSA != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just want to confirm that Name is required to add the DSA object such that if LegalName is present but Name is not, you don't want to add the DSA object. Is that correct?

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, c13c6ff

adnuntius

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:98:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:108:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:112:	setHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:128:	makeEndpointUrl		92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:177:	getImpSizes		90.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:200:	generateRequests	92.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:316:	MakeBids		81.8%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:343:	getSiteExtAsKv		80.0%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:353:	getGDPR			92.9%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:378:	generateReturnExt	86.7%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:412:	generateAdResponse	82.1%
github.com/prebid/prebid-server/v2/adapters/adnuntius/adnuntius.go:485:	generateBidResponse	88.0%
total:									(statements)		89.4%

@bsardo bsardo merged commit 3c4527e into prebid:master Sep 18, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for Dev
Development

Successfully merging this pull request may close these issues.

3 participants