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

Privacy Sandbox: Topics in headers #3393

Merged

Conversation

pm-nilesh-chate
Copy link
Contributor

@pm-nilesh-chate pm-nilesh-chate commented Jan 10, 2024

Implements #3008

@bsardo bsardo changed the title support Topics in headers #3008 Topics in headers Jan 12, 2024
@bsardo bsardo self-assigned this Jan 12, 2024
@SyntaxNode SyntaxNode self-assigned this Jan 16, 2024
@pm-nilesh-chate pm-nilesh-chate changed the title Topics in headers Privacy Sandbox: Topics in headers #3008 Jan 19, 2024
@pm-nilesh-chate pm-nilesh-chate marked this pull request as ready for review January 19, 2024 09:31
config/config.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction_test.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction_test.go Show resolved Hide resolved
@bsardo bsardo changed the title Privacy Sandbox: Topics in headers #3008 Privacy Sandbox: Topics in headers Jan 24, 2024
endpoints/openrtb2/amp_auction.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction.go Outdated Show resolved Hide resolved
endpoints/openrtb2/auction.go Outdated Show resolved Hide resolved
endpoints/openrtb2/video_auction.go Outdated Show resolved Hide resolved
privacysandbox/topics.go Outdated Show resolved Hide resolved
privacysandbox/topics_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AlexBVolcy AlexBVolcy left a comment

Choose a reason for hiding this comment

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

Looks good, left two very minor comments.

privacysandbox/topics.go Outdated Show resolved Hide resolved
privacysandbox/topics_test.go Outdated Show resolved Hide resolved
@pm-nilesh-chate
Copy link
Contributor Author

The spec mentions that invalid entires should result in an error, but are ignored in this implementation.

The specification includes requirement 3.viii "If any validation fails, that header field should be ignored with a warning when in debug mode". That is not implemented in this PR. To implement, warnings should pass along the error chain to be filtered by the top level call to setFieldsImplicitly. Please try to match error wording from PBS-Java (if they have this implemented already).

@SyntaxNode Logging in setFieldsImplicitly for only debug mode is a bit tricky. Debug mode status is available in HoldAuction(). I would have to add warning logs (with new debug severity) in setFieldsImplicitly and remove these logs using errortypes.WithoutDebugWarnings(errs) while create response.ext inmakeExtBidResponse if debug is not enabled. Let me know if this approach is ok or do you suggest any other

@SyntaxNode
Copy link
Contributor

SyntaxNode commented Mar 18, 2024

@SyntaxNode Logging in setFieldsImplicitly for only debug mode is a bit tricky. Debug mode status is available in HoldAuction(). I would have to add warning logs (with new debug severity) in setFieldsImplicitly and remove these logs using errortypes.WithoutDebugWarnings(errs) while create response.ext inmakeExtBidResponse if debug is not enabled. Let me know if this approach is ok or do you suggest any other

I think it's better to emit warnings without checking the debug flag than emit no warnings at all. We can add the debug descriptor in the future if it's needed.

IMHO it's ok to use the existing warning functionality. Look at how errors are handled by deps.validateRequest to see how to pass warnings into HoldAuction for inclusion in the response. (which isn't ideal, but it's the way things are right now)

If you want to follow the debug requirement, I don't think you need to create a new severity level. The severity is primarily used to know when to end the auction early and how to classify the error in the response. I think we may be ok with adding a signal to the Coder interface and adding a WarningDebugOnly helper to filter out debug scoped warnings when debug is false.

@pm-nilesh-chate
Copy link
Contributor Author

@SyntaxNode please review the latest changes. I'll add the UT, etc once the approach is accepted.

Copy link
Contributor

@SyntaxNode SyntaxNode left a comment

Choose a reason for hiding this comment

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

Thank you for updating the PR to include warning. I appreciate that you want to fully implement the debug condition.

Adding a new severity level is opening us up to potential bugs. There is a good amount of code which assumes an error is either fatal or a warning, but now these cases need to be expanded to include debug warnings. Some of the code pathways may be missed (we're only human, after all). I also expect this would be a large effort to test.

The only difference between a warning and a debug warning is when to write it to the response. All other code pathways are unchanged.

I recommended adding a property of some kind to the warning type which will identify it's scope. You only need to change the warning loop in exchange.go - which introduces less risk and requires less testing.

Thinking about it more, consider adding a scope.go in the errortypes package which looks something like this:

type Scope int

const (
  ScopeAny
  ScopeDebug
)

type Scoped interface {
  Scope() Scope
}

func ReadScope(err error) Scope {
  if e, ok := err.(Scoped); ok {
    return e.Scope()
  }
  return ScopeAny
}

When looping through errors, if debug is not enabled ignore any warnings with the ScopeDebug scope. You can still create a DebugWarning type with it implementing the Scoped interface and returning a ScopeDebug value. The default will be treat warnings as we do today.

endpoints/openrtb2/amp_auction.go Show resolved Hide resolved
endpoints/openrtb2/auction.go Show resolved Hide resolved
endpoints/openrtb2/video_auction.go Outdated Show resolved Hide resolved
@pm-nilesh-chate
Copy link
Contributor Author

@SyntaxNode Thanks for the prompt review. Could you please review the latest commit which implements the recommended changes

@SyntaxNode
Copy link
Contributor

@SyntaxNode Thanks for the prompt review. Could you please review the latest commit which implements the recommended changes

Looks good to me. Thank you for acting on this feedback.

AlexBVolcy
AlexBVolcy previously approved these changes Mar 23, 2024
@AlexBVolcy AlexBVolcy dismissed their stale review March 26, 2024 17:53

New comments

Copy link
Contributor

@AlexBVolcy AlexBVolcy left a comment

Choose a reason for hiding this comment

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

Just found some things related to code coverage I wanted to ask about, and a spelling nitpick.

endpoints/openrtb2/auction_test.go Outdated Show resolved Hide resolved
endpoints/openrtb2/amp_auction.go Show resolved Hide resolved
errortypes/scope.go Show resolved Hide resolved
AlexBVolcy
AlexBVolcy previously approved these changes Mar 27, 2024
@bsardo bsardo removed their assignment Apr 1, 2024
Copy link
Contributor

@SyntaxNode SyntaxNode left a comment

Choose a reason for hiding this comment

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

Thank you for the updates. Looking good to me. I performed end-to-end testing via Postman. I found it difficult to setup a test via the Chrome browser itself. I used different test topics posted by Google and they all worked well.

A few small nitpicks before I approve.

endpoints/openrtb2/amp_auction_test.go Show resolved Hide resolved
endpoints/openrtb2/amp_auction_test.go Show resolved Hide resolved
privacysandbox/topics.go Outdated Show resolved Hide resolved
privacysandbox/topics.go Outdated Show resolved Hide resolved
config/account.go Show resolved Hide resolved
@SyntaxNode SyntaxNode merged commit e982bfe into prebid:master Apr 3, 2024
3 checks passed
@pm-nilesh-chate pm-nilesh-chate deleted the issue-3008-topics-in-headers-1 branch April 4, 2024 08:35
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.

None yet

4 participants