Skip to content

New Adapter: Synapse HX#4795

Merged
bsardo merged 5 commits into
prebid:masterfrom
prebid-compas:implement-synapsehx-adapter
Jun 9, 2026
Merged

New Adapter: Synapse HX#4795
bsardo merged 5 commits into
prebid:masterfrom
prebid-compas:implement-synapsehx-adapter

Conversation

@prebid-compas

@prebid-compas prebid-compas commented May 26, 2026

Copy link
Copy Markdown
Contributor

@prebid-compas prebid-compas marked this pull request as ready for review May 26, 2026 17:02
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

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, 0a22422

synapseHX

Refer here for heat map coverage report

github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:20:	Builder			100.0%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:28:	MakeRequests		82.4%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:66:	MakeBids		94.7%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:106:	buildRequestHeaders	100.0%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:115:	getMediaTypeForBid	76.9%
total:									(statements)		87.5%

@@ -0,0 +1,21 @@
endpoint: "https://rtb.hx.compasonline.com/pbs"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified the endpoint is live

curl -i --location --request POST "https://rtb.hx.compasonline.com/pbs"
HTTP/1.1 400 Bad Request
Content-Length: 0
Date: Tue, 02 Jun 2026 20:30:19 GMT
Server: Kestrel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you.

@@ -0,0 +1,21 @@
endpoint: "https://rtb.hx.compasonline.com/pbs"
maintainer:
email: prebid@compas-inc.com

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We've sent an email to this address. Please respond to the email to verify that it is reachable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified receipt.

Comment on lines +16 to +18
redirect:
url: "https://sync.hx.compasonline.com/pbserver/image?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&ccpa={{.USPrivacy}}&gpp={{.GPP}}&gpp_sid={{.GPPSID}}&redirect={{.RedirectURL}}"
userMacro: "${VISITOR_ID}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this endpoint live? I sent the following request which hangs:
https://sync.hx.compasonline.com/pbserver/image?gdpr=0&gdpr_consent=&ccpa=&gpp=&gpp_sid=&redirect=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3DsynapseHX%26gdpr%3D0%26gdpr_consent%3D%26gpp%3D%26gpp_sid%3D%26f%3Di%26uid%3D%24%7BVISITOR_ID%7D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you. Endpoint has been fixed.

url: "https://sync.hx.compasonline.com/pbserver/image?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&ccpa={{.USPrivacy}}&gpp={{.GPP}}&gpp_sid={{.GPPSID}}&redirect={{.RedirectURL}}"
userMacro: "${VISITOR_ID}"
iframe:
url: "https://sync.hx.compasonline.com/pbserver/iframe?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&ccpa={{.USPrivacy}}&gpp={{.GPP}}&gpp_sid={{.GPPSID}}&redirect={{.RedirectURL}}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this endpoint live? I sent the following request which hangs:
https://sync.hx.compasonline.com/pbserver/iframe?gdpr=0&gdpr_consent=&ccpa=&gpp=&gpp_sid=&redirect=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3DsynapseHX%26gdpr%3D0%26gdpr_consent%3D%26gpp%3D%26gpp_sid%3D%26f%3Db%26uid%3D%24%7BVISITOR_ID%7D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you. Endpoint has been fixed.

Comment on lines +120 to +124
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
default:
return "", fmt.Errorf("unsupported media type %d", bid.MType)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add supplemental JSON tests to cover these cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread adapters/synapseHX/synapseHX.go Outdated
Comment on lines +36 to +43
if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil {
errors = append(errors, fmt.Errorf("failed to unmarshal bidder ext: %w", err))
}

var ext openrtb_ext.ExtImpSynapseHX
if err := json.Unmarshal(bidderExt.Bidder, &ext); err != nil {
errors = append(errors, fmt.Errorf("failed to unmarshal bidder parameters: %w", err))
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If you're unable to successfully unmarshal the bidder params, you won't have the tenant ID. In that case, I think you want to early return with nil, errors instead of hitting the bidder endpoint with no tenant ID. Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread adapters/synapseHX/synapseHX.go Outdated

requestBody, err := jsonutil.Marshal(request)
if err != nil {
errors = append(errors, fmt.Errorf("failed to marshal request: %w", err))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same thing here, early return nil, errors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

var errs []error
bidderResponse := adapters.NewBidderResponseWithBidsCapacity(len(bidResponse.SeatBid[0].Bid))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I suggest ensuring there is at least one seatbid before attempting to access the first element.
Something like:

if len(bidResponse.SeatBid) == 0 {
	return nil, nil
}

or

if len(bidResponse.SeatBid) == 0 {
	return nil, []error{&errortypes.BadServerResponse{
		Message: "Empty SeatBid array",
	}}
}

depending on what makes sense for you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread adapters/synapseHX/synapseHX.go Outdated
Comment on lines +99 to +101
if len(bidResponse.SeatBid) == 0 || len(bidResponse.SeatBid[0].Bid) == 0 {
return nil, nil
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this can be deleted. I suggested a check above to ensure there is a seat bid before sizing the bidder response.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If the server returns a valid 200 response with an empty seatbid array, this panics at runtime. The empty-check must come before SeatBid[0] is indexed. This is likely the same issue flagged by reviewer @bsardo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

var errs []error
bidderResponse := adapters.NewBidderResponseWithBidsCapacity(len(bidResponse.SeatBid[0].Bid))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please also cover the new logic I suggested above with a supplemental JSON test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread adapters/synapseHX/synapseHX.go Outdated

if len(request.Imp) > 0 {
var bidderExt adapters.ExtImpBidder
if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A failed first unmarshal leaves bidderExt.Bidder as nil, then the second unmarshal proceeds on bad state. Both unmarshal errors should return early.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread adapters/synapseHX/synapseHX.go Outdated
}

var ext openrtb_ext.ExtImpSynapseHX
if err := json.Unmarshal(bidderExt.Bidder, &ext); err != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should consistently use jsonutil.Unmarshal throughout.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread openrtb_ext/imp_synapseHX.go Outdated

type ExtImpSynapseHX struct {
TenantID string `json:"tenantId"`
AdUnitID string `json:"adUnitId,omitempty"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ExtImpSynapseHX.AdUnitID is defined and present in the JSON schema (adUnitId), but the adapter never reads or forwards it. Either use it or remove it. Leaving it creates false expectations for publishers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}
adapterstest.RunJSONBidderTest(t, "synapseHXtest", bidder)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The convention in this repo is to pass the adapter directory name (e.g., "synapseHX"), not "synapseHXtest". This may cause the test to silently look in the wrong directory.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you.

We checked this across the repository and based on the existing usage examples it does not match with your suggestion - here are a few screenshots from the repo for reference. The same behavior also seems to be aligned with the official documentation here: https://docs.prebid.org/prebid-server/developers/add-new-bidder-go.html#test-your-adapter

Please, let us know your opinion. On our side, we have ready-to-push change to address this.
image
image

"github.com/prebid/prebid-server/v4/openrtb_ext"
)

func TestValidParams(t *testing.T) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As flagged by @bsardo, tests are missing for:

  • Empty seatbid array in response
  • request.Imp is empty
  • Unmarshal failure on impression ext
  • getMediaTypeForBid with no mtype and no bid.ext

The reported 76.9% coverage on getMediaTypeForBid confirms these gaps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tests were added.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

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, 2033b28

synapseHX

Refer here for heat map coverage report

github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:20:	Builder			100.0%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:28:	MakeRequests		95.2%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:72:	MakeBids		100.0%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:112:	buildRequestHeaders	100.0%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:121:	getMediaTypeForBid	92.3%
total:									(statements)		96.7%

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

synapseHX

Refer here for heat map coverage report

github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:20:	Builder			100.0%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:28:	MakeRequests		95.2%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:72:	MakeBids		100.0%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:112:	buildRequestHeaders	100.0%
github.com/prebid/prebid-server/v4/adapters/synapseHX/synapseHX.go:121:	getMediaTypeForBid	92.3%
total:									(statements)		96.7%

@bsardo bsardo added the adapter label Jun 9, 2026
@bsardo bsardo merged commit f5f6439 into prebid:master Jun 9, 2026
6 checks passed
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.

3 participants