@@ -503,24 +503,32 @@ describe("parallel web search provider", () => {
503503 expect ( ( error as Error ) . message ) . not . toContain ( apiKey ) ;
504504 } ) ;
505505 it ( "applies configured logging.redactPatterns to reflected Parallel error bodies" , async ( ) => {
506- // Organization-specific secret shape that no built-in pattern covers.
506+ // Organization-specific secret shape that no built-in pattern covers, plus a
507+ // configured field-name pattern that would rewrite the x-api-key header name
508+ // before the structured matcher can see it — the key value must stay masked.
507509 const orgSecret = "acme-internal-bluefin-042" ;
510+ const apiKey = "par-live-4c9d2e7ab1f0c9d2e7ab1f0c9d2e7" ;
508511 const configDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "parallel-redact-config-" ) ) ;
509512 const configPath = path . join ( configDir , "openclaw.json" ) ;
510513 fs . writeFileSync (
511514 configPath ,
512- JSON . stringify ( { logging : { redactPatterns : [ "acme-internal-[a-z0-9-]+" ] } } ) ,
515+ JSON . stringify ( {
516+ logging : { redactPatterns : [ "acme-internal-[a-z0-9-]+" , "api[_-]?key" ] } ,
517+ } ) ,
513518 ) ;
514519 vi . stubEnv ( "OPENCLAW_CONFIG_PATH" , configPath ) ;
515520 try {
516521 endpointMockState . responses . push (
517- new Response ( `<html><body>edge failure for ${ orgSecret } </body></html>` , {
518- status : 502 ,
519- statusText : "Bad Gateway" ,
520- headers : { "Content-Type" : "text/html" } ,
521- } ) ,
522+ new Response (
523+ `<html><body>edge failure for ${ orgSecret } on request with x-api-key: ${ apiKey } </body></html>` ,
524+ {
525+ status : 502 ,
526+ statusText : "Bad Gateway" ,
527+ headers : { "Content-Type" : "text/html" } ,
528+ } ,
529+ ) ,
522530 ) ;
523- const error = await paidTool ( )
531+ const error = await paidTool ( { parallel : { apiKey } } )
524532 . execute ( {
525533 objective : `parallel-error-redact-config-${ Date . now ( ) } ` ,
526534 search_queries : [ "openclaw" ] ,
@@ -529,6 +537,7 @@ describe("parallel web search provider", () => {
529537 expect ( error ) . toBeInstanceOf ( Error ) ;
530538 expect ( ( error as Error ) . message ) . toContain ( "Parallel API error (502)" ) ;
531539 expect ( ( error as Error ) . message ) . not . toContain ( orgSecret ) ;
540+ expect ( ( error as Error ) . message ) . not . toContain ( apiKey ) ;
532541 } finally {
533542 vi . unstubAllEnvs ( ) ;
534543 fs . rmSync ( configDir , { force : true , recursive : true } ) ;
0 commit comments