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

Frank fpd issue #3455

Merged
merged 5 commits into from
Jan 25, 2019
Merged

Frank fpd issue #3455

merged 5 commits into from
Jan 25, 2019

Conversation

robertrmartinez
Copy link
Collaborator

Type of change

  • Bugfix

Description of change

Noticed that we do not check the validity of visitor and inventory fpd values before forwarding through.

If each key in the inventory or visitor object is not an array of values, FRANK will 400.

This change verifies they are arrays before attaching them.

Copy link
Contributor

@idettman idettman left a comment

Choose a reason for hiding this comment

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

existing code LGTM, with the exception of the note below

Copy link
Contributor

@idettman idettman left a comment

Choose a reason for hiding this comment

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

Consider adding logic to wrap string or number in array.

if (Array.isArray(params.visitor[key])) {
  slotData.visitor[key] = params.visitor[key]
} else if ((typeof params.visitor[key] === 'string' && params.visitor[key] !== '') || typeof params.visitor[key] === 'number') {
  slotData.visitor[key] = [params.visitor[key]]
}

Copy link
Collaborator

@harpere harpere left a comment

Choose a reason for hiding this comment

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

I like @idettman's suggestion about putting scalars in arrays.

let value = params.visitor[key];
if (Array.isArray(value)) {
  slotData.visitor[key] = value;
} else if ((typeof value === 'string' && value !== '') || typeof value === 'number') {
  slotData.visitor[key] = [value];
}

expect(slot.visitor).to.have.property('ucat').that.equals('new');
expect(slot.visitor).to.have.property('lastsearch').that.equals('iphone');
expect(slot.visitor).to.have.property('ucat').that.deep.equals(['new']);
expect(slot.visitor).to.have.property('lastsearch').that.deep.equals(['iphone']);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now instead of sending a bad request it is sending the array wrapped data which will be accepted by Frank.


if (params.keywords && Array.isArray(params.keywords)) {
slotData.keywords = params.keywords;
}

if (params.visitor && typeof params.visitor === 'object') {
slotData.visitor = params.visitor;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

combined both visitor and inventory into one block since they have same requirements and necessary checks.

Copy link
Collaborator

@harpere harpere left a comment

Choose a reason for hiding this comment

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

LGTM

@harpere harpere merged commit a8eb239 into prebid:master Jan 25, 2019
pedrolopezmrf pushed a commit to Marfeel/Prebid.js that referenced this pull request Mar 18, 2019
* Changing to requestId in order to align with prebid cores mapping of bidId to responseId

* Rubi Bid Adapter: Do not pass non-array FPD to Frank Video

* Updating based on review + tests
@robertrmartinez robertrmartinez deleted the frank_fpd_issue branch July 5, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants