@@ -41,6 +41,17 @@ const ZONE_KEY: &str = "zone";
4141/// Default currency for `OpenRTB` bid floors and responses.
4242const DEFAULT_CURRENCY : & str = "USD" ;
4343
44+ /// Maximum number of characters from upstream failure payloads included in
45+ /// debug-facing `body_preview` metadata.
46+ const PREBID_ERROR_BODY_PREVIEW_CHARS : usize = 1000 ;
47+
48+ fn prebid_body_preview ( body : & [ u8 ] ) -> String {
49+ String :: from_utf8_lossy ( body)
50+ . chars ( )
51+ . take ( PREBID_ERROR_BODY_PREVIEW_CHARS )
52+ . collect ( )
53+ }
54+
4455/// CCPA/US-privacy string sent when the `Sec-GPC` header signals opt-out.
4556///
4657/// Encodes: version `1`, notice given (`Y`), user opted out (`Y`), LSPA not
@@ -1594,31 +1605,23 @@ impl AuctionProvider for PrebidAuctionProvider {
15941605pub fn register_auction_provider (
15951606 settings : & Settings ,
15961607) -> Result < Vec < Arc < dyn AuctionProvider > > , Report < TrustedServerError > > {
1597- let mut providers: Vec < Arc < dyn AuctionProvider > > = Vec :: new ( ) ;
1608+ let Some ( integration) = build ( settings) ? else {
1609+ log:: info!( "Prebid auction provider not registered: integration not found or disabled" ) ;
1610+ return Ok ( Vec :: new ( ) ) ;
1611+ } ;
15981612
1599- match settings. integration_config :: < PrebidIntegrationConfig > ( PREBID_INTEGRATION_ID ) {
1600- Ok ( Some ( config) ) => {
1601- log:: info!(
1602- "Registering Prebid auction provider (server_url={})" ,
1603- config. server_url
1604- ) ;
1605- if config. debug {
1606- log:: warn!(
1607- "Prebid debug mode is ON — debug data (httpcalls, resolvedrequest, \
1608- bidstatus) will be included in /auction responses"
1609- ) ;
1610- }
1611- providers. push ( Arc :: new ( PrebidAuctionProvider :: new ( config) ) ) ;
1612- }
1613- Ok ( None ) => {
1614- log:: info!( "Prebid auction provider not registered: integration not found or disabled" ) ;
1615- }
1616- Err ( e) => {
1617- return Err ( e) ;
1618- }
1613+ log:: info!(
1614+ "Registering Prebid auction provider (server_url={})" ,
1615+ integration. config. server_url
1616+ ) ;
1617+ if integration. config . debug {
1618+ log:: warn!(
1619+ "Prebid debug mode is ON — debug data (httpcalls, resolvedrequest, \
1620+ bidstatus) will be included in /auction responses"
1621+ ) ;
16191622 }
16201623
1621- Ok ( providers )
1624+ Ok ( vec ! [ Arc :: new ( integration . auction_provider ( ) ) ] )
16221625}
16231626
16241627#[ cfg( test) ]
@@ -3277,9 +3280,7 @@ server_url = "https://prebid.example"
32773280 "should include upstream HTTP status"
32783281 ) ;
32793282 assert ! (
3280- !auction_response
3281- . metadata
3282- . contains_key( "body_preview" ) ,
3283+ !auction_response. metadata. contains_key( "body_preview" ) ,
32833284 "should omit upstream body preview unless Prebid debug is enabled"
32843285 ) ;
32853286 }
0 commit comments