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

ImproveDigital: Bad-Input Error #3469

Merged
merged 2 commits into from
Feb 13, 2024
Merged

Conversation

ishihanvcs
Copy link
Contributor

@ishihanvcs ishihanvcs commented Feb 6, 2024

EDIT: Forward fix for prebid/prebid-server-java#2942

Original issue is found & reported on pbs java. As the pbs go adapters are continuously being ported to java version, we want to fix this here first and then provide fix in the java version.

Please review & merge kindly at your earliest convenience.

TIA

Copy link

github-actions bot commented Feb 6, 2024

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, 3af8a65

improvedigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:49:	MakeRequests				87.5%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:66:	makeRequest				84.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:106:	MakeBids				97.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:181:	Builder					100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:188:	getBidType				100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:240:	isMultiFormatImp			100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:258:	getAdditionalConsentProvidersUserExt	78.1%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:320:	getImpExtWithRewardedInventory		81.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:349:	buildEndpointURL			100.0%
total:											(statements)				90.0%

Copy link

github-actions bot commented Feb 6, 2024

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

improvedigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:49:	MakeRequests				87.5%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:66:	makeRequest				84.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:106:	MakeBids				97.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:181:	Builder					100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:188:	getBidType				100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:240:	isMultiFormatImp			100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:258:	getAdditionalConsentProvidersUserExt	78.1%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:320:	getImpExtWithRewardedInventory		81.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:349:	buildEndpointURL			100.0%
total:											(statements)				90.0%

@SyntaxNode SyntaxNode changed the title forward fix for https:/prebid/prebid-server-java/issues/2942 ImproveDigital: Bad-Input Error Feb 6, 2024
@@ -276,7 +276,7 @@ func (a *ImprovedigitalAdapter) getAdditionalConsentProvidersUserExt(request ope
}

// Check key exist user.ext.ConsentedProvidersSettings.consented_providers
var cpMap = make(map[string]json.RawMessage)
var cpMap = make(map[string]interface{})
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 please add a json test case for this change.

@@ -276,7 +276,7 @@ func (a *ImprovedigitalAdapter) getAdditionalConsentProvidersUserExt(request ope
}

// Check key exist user.ext.ConsentedProvidersSettings.consented_providers
var cpMap = make(map[string]json.RawMessage)
var cpMap = make(map[string]interface{})
Copy link
Contributor

Choose a reason for hiding this comment

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

@ishihanvcs any particular reason to use interface{} here? this change add step for asserting cMapValue to string (line 291)

consentStr := cpMapValue.(string)

On line 291, adapter code is not checking whether cpMapValue can be asserted into string. This could led to panic at run time. Refer https://go.dev/play/p/BnmZ2ZGjT3E as example

Additionally json.RawMessage does gurantee that value parsed in cpMap will be a valid json which can be converted further into string. But with interface{} cpMap can have any value

if len(cpStr) == 0 {
return nil, nil
}
//cpStr = consentStr[:len(consentStr)-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

could remove this code comment

@ishihanvcs
Copy link
Contributor Author

@onkarvhanumante Thanks for pointing out the issue precisely. As an occasional go developer, I was too hasty to look forward all possible execution path. I'll soon revert var cpMap = make(map[string]interface{}) to var cpMap = make(map[string]json.RawMessage) and update accordingly.

Also, I'll add a supplemental test for the multi ~ case in the value of consented_providers key.

Copy link

github-actions bot commented Feb 8, 2024

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

improvedigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:49:	MakeRequests				87.5%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:66:	makeRequest				84.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:106:	MakeBids				97.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:181:	Builder					100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:188:	getBidType				100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:240:	isMultiFormatImp			100.0%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:258:	getAdditionalConsentProvidersUserExt	78.1%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:320:	getImpExtWithRewardedInventory		81.2%
github.com/prebid/prebid-server/v2/adapters/improvedigital/improvedigital.go:349:	buildEndpointURL			100.0%
total:											(statements)				90.0%

@ishihanvcs
Copy link
Contributor Author

@onkarvhanumante @gargcreation1992 Code updated. Please review & merge if found okay.

@gargcreation1992 gargcreation1992 merged commit 2848f6b into prebid:master Feb 13, 2024
5 checks passed
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