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

New Adapter: Seedtag #4198

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sangarbe
Copy link

documentation PR - prebid/prebid.github.io#5866

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, 42015ca

seedtag

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:22:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:30:	MakeRequests		50.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:61:	MakeBids		85.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:105:	getMediaTypeForBid	100.0%
total:									(statements)		76.3%

@bsardo bsardo added the adapter label Feb 11, 2025
@bsardo bsardo self-assigned this Feb 12, 2025
@bsardo
Copy link
Collaborator

bsardo commented Feb 13, 2025

@ccorbo can you give this the first look?

@ccorbo
Copy link
Contributor

ccorbo commented Feb 13, 2025

Endpoint returns a 400 - is this expected?

image

Confirmed user syncing works correctly:
image

Confirmed GLV ID:
image

Sent email to mainter email address to verify.

@@ -0,0 +1,69 @@
{
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 add a test where you receive a bid with an unexpected mtype?

Copy link
Author

Choose a reason for hiding this comment

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

added this test and also a test for currency conversion errors

@ccorbo
Copy link
Contributor

ccorbo commented Feb 14, 2025

Confirmed maintainer email:
image

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, 4a25163

seedtag

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:22:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:30:	MakeRequests		85.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:73:	MakeBids		95.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:117:	getMediaTypeForBid	100.0%
total:									(statements)		91.3%

@sangarbe
Copy link
Author

The 400 error is expected if not providing an OpenRtb well formed payload


var invalidParams = []string{
`{"adUnitId": 123}`,
`{"adUnitId": ""}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since adUnitId is a required param, I suggest adding a case where adUnitId is not provided: {}


func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderSeedtag, config.Adapter{
Endpoint: "https://s.seedtag.com"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: I suggest using a test url for maintenance purposes.

Comment on lines 74 to 86
if responseData.StatusCode == http.StatusNoContent {
return nil, nil
}

if responseData.StatusCode == http.StatusBadRequest {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info", responseData.StatusCode),
}}
}

if responseData.StatusCode != http.StatusOK {
return nil, []error{fmt.Errorf("unexpected status code: %d. Run with request.debug = 1 for more info", responseData.StatusCode)}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that the prebid docs do not reflect this yet but please use the adapter utility functions adapters/response.go#IsResponseStatusCodeNoContent and adapters/response.go#CheckResponseStatusCodeForErrors to handle invalid status codes.


requestCopy := *request
requestCopy.Imp = imps
requestJSON, err := json.Marshal(requestCopy)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use jsonutil.Marshal instead of json.Marshal.

return nil, []error{err}
}

bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: It might be better to size this based on the number of valid impressions rather than the initial number of impressions. You should be able to access the valid impression count via requestData.ImpIDs.

case 2:
return openrtb_ext.BidTypeVideo, nil
default:
return "", fmt.Errorf("bid.MType invalid")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: I suggest errors.New for errors that are just string literals.

adapterstest.RunJSONBidderTest(t, "seedtagtest", bidder)
}

func TestGetMediaTypeForBid(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

All code coverage should be achieved via the JSON framework wherever possible. You've achieved full coverage of the GetMediaTypeForBid function through your JSON tests so I don't see this unit test offering much value. I suggest deleting it but you can keep it if you like.

If you decide to keep it, please do the following:

  1. replace all spaces in your test names with underscores (e.g. "video mediaType" becomes "video_mediaType"
  2. fix typo "invalie"
  3. replace body with the following using t.Run and removing wantErrContain:
for _, test := range tests {
	t.Run(test.name, func(t *testing.T) {
		var bid openrtb2.Bid
		bid.MType = openrtb2.MarkupType(test.value)

		got, gotErr := getMediaTypeForBid(bid)
		assert.Equal(t, test.want, got)

		if test.wantErr {
			assert.Error(t, gotErr)	
		}
	})
}

Copy link
Author

Choose a reason for hiding this comment

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

right! I just removed it

Comment on lines +44 to +45
imp.BidFloorCur = "USD"
imp.BidFloor = convertedValue
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two lines are missing test coverage. Please add a supplemental JSON test where a successful currency conversion takes place.

Copy link
Author

Choose a reason for hiding this comment

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

test added


var response openrtb2.BidResponse
if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil {
return nil, []error{err}
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 a supplemental JSON test where the response body unmarshaling fails.

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, dd4b3ae

seedtag

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:20:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:28:	MakeRequests		95.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:71:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/seedtag/seedtag.go:110:	getMediaTypeForBid	100.0%
total:									(statements)		97.8%

@sangarbe
Copy link
Author

Hi @bsardo I've done all changes you pointed out, thanks for the catches ;)

@sangarbe sangarbe requested a review from bsardo February 20, 2025 11:32
@bsardo bsardo assigned ccorbo and unassigned VeronikaSolovei9 Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants