Lasso Bid Adapter: fix meta.secondaryCatIds/advertiserDomains field mapping - #15565
Lasso Bid Adapter: fix meta.secondaryCatIds/advertiserDomains field mapping#15565sujanchalla0510 wants to merge 2 commits into
Conversation
…apping interpretResponse() read secondaryCatIds and advertiserDomains from response.bid.cat / response.bid.advertiserDomains, but the adapter's own server response shape (per its test fixture, and consistent with how the adjacent advertiserName field is correctly read two lines below) carries these under a top-level response.meta object, sibling to response.bid -- not as properties of response.bid. response.bid never has cat/advertiserDomains keys, so every real bid response produces meta.secondaryCatIds/meta.advertiserDomains equal to undefined, unconditionally. The existing interpretResponse test's own fixture already puts these fields under body.meta (matching the real wire format), but the assertion only compared Object.keys(result[0]) against Object.keys(expectedResponse) -- a keys-only structural check that never inspects values, so it passed even though every affected field resolved to undefined. Fix: read both fields from response.meta, matching the pattern already used for advertiserName. Extended the existing test to also assert deep equality of the full response object, not just its key set, so a wrong source path is actually caught going forward. Verified by reverting only modules/lassoBidAdapter.js (keeping the updated test): the new deep-equal assertion fails against the unfixed code with - "advertiserDomains": [undefined] + "advertiserDomains": ["lassomarketing.io"] - "secondaryCatIds": [undefined] + "secondaryCatIds": ["1", "2", "3", "4"] Restoring the fix makes it pass. gulp lint: clean. gulp test-only (all 8 chunks): passing, no failures. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NFth3sHBrJbHuFeA8Cegdc
| meta: { | ||
| secondaryCatIds: response.bid.cat, | ||
| advertiserDomains: response.bid.advertiserDomains, | ||
| secondaryCatIds: response.meta.cat, |
There was a problem hiding this comment.
please add the fallback to the original place so the team working on the server response can move it around if they need to and have publishers that have upgraded to whenever this is released agnostic to the location
There was a problem hiding this comment.
Good point — done. interpretResponse now reads response.meta.cat/response.meta.advertiserDomains first, but falls back to the original response.bid.cat/response.bid.advertiserDomains location if the server response doesn't carry them under meta. That way the mapping stays agnostic to wherever the server response places these fields going forward, and publishers on either response shape keep working. Added a test case (should fall back to response.bid.cat/advertiserDomains when response.meta does not carry them) that exercises the fallback path — confirmed it fails without the fallback and passes with it. Pushed in 10f2e2c.
…serDomains location Per review feedback, keep reading secondaryCatIds/advertiserDomains from response.meta.cat/advertiserDomains first, but fall back to the original response.bid.cat/response.bid.advertiserDomains location if the server response doesn't carry them under meta. This keeps interpretResponse agnostic to where the server team places these fields, so publishers on either response shape keep working.
Summary
modules/lassoBidAdapter.js'sinterpretResponse()buildsmeta.secondaryCatIdsandmeta.advertiserDomainsfromresponse.bid.cat/response.bid.advertiserDomains:https://github.com/prebid/Prebid.js/blob/master/modules/lassoBidAdapter.js#L124-L129
but the adapter's own response shape (confirmed by its own test fixture) carries
catandadvertiserDomainsunder a top-levelresponse.metaobject, a sibling ofresponse.bid— not a property of it. The adjacentadvertiserNamefield on the very next line already reads correctly fromresponse.meta.advertiserName, which is the internal-consistency tell that this was a copy/paste slip rather than an intentional shape.response.bid(per the request payload the endpoint returns —price,w,h,crid,ad,mediaType) never carriescatoradvertiserDomains, someta.secondaryCatIdsandmeta.advertiserDomainsresolve toundefinedon every real bid response, unconditionally — not an edge case gated on some optional field being absent, just a wrong root object.Why the existing test didn't catch this: the test's own response fixture already puts
cat: [...]andadvertiserDomains: [...]underbody.meta(the real, correct wire shape), so the fixture itself never masked anything about the server contract. What masked the bug was the assertion:https://github.com/prebid/Prebid.js/blob/master/test/spec/modules/lassoBidAdapter_spec.js#L394-L395
This only compares the set of keys present on the result, never the values.
meta: { secondaryCatIds: undefined, advertiserDomains: undefined, ... }still has the same keys as the expected object, so the assertion passed despite both fields silently resolving toundefined.Fix
Read both fields from
response.meta, matching the already-correct pattern used foradvertiserNametwo lines below.Verification
Extended the existing
interpretResponsetest to also assert fulldeep.equalon the response object (in addition to the pre-existing key-set check), so a wrong source path is actually caught going forward.Verified by reverting only
modules/lassoBidAdapter.js(keeping the updated test) and re-running: the new assertion fails against the unfixed code withRestoring the fix makes it pass.
npx gulp lint --files modules/lassoBidAdapter.js,test/spec/modules/lassoBidAdapter_spec.js: clean, no changes needed.npx gulp test-only --file test/spec/modules/lassoBidAdapter_spec.js: 36/36 passing.npx gulp test-only(full suite, all 8 chunks): all passing (no new failures).Scope
Single, narrowly-scoped bugfix to one adapter file plus its test spec — no other behavior changes.
🤖 Generated with Claude Code