@@ -603,12 +603,33 @@ describe("safe_outputs_handlers", () => {
603603 const responseData = JSON . parse ( result . content [ 0 ] . text ) ;
604604 expect ( responseData . result ) . toBe ( "error" ) ;
605605 expect ( responseData . error ) . toContain ( "Invalid patch_format" ) ;
606- expect ( responseData . error ) . toContain ( "invalid-format" ) ;
607606 expect ( responseData . error ) . toContain ( "am" ) ;
608607 expect ( responseData . error ) . toContain ( "bundle" ) ;
608+ // Must not echo the raw resolved value (could be a secret expression result)
609+ expect ( responseData . error ) . not . toContain ( "invalid-format" ) ;
609610 // Must not have appended any safe output
610611 expect ( mockAppendSafeOutput ) . not . toHaveBeenCalled ( ) ;
611612 } ) ;
613+
614+ it ( "should fail closed when patch_format resolves to an empty string" , async ( ) => {
615+ handlers = createHandlers ( mockServer , mockAppendSafeOutput , {
616+ create_pull_request : {
617+ patch_format : "" ,
618+ } ,
619+ } ) ;
620+
621+ const result = await handlers . createPullRequestHandler ( {
622+ branch : "feature-branch" ,
623+ title : "Test PR" ,
624+ body : "Test description" ,
625+ } ) ;
626+
627+ expect ( result . isError ) . toBe ( true ) ;
628+ const responseData = JSON . parse ( result . content [ 0 ] . text ) ;
629+ expect ( responseData . result ) . toBe ( "error" ) ;
630+ expect ( responseData . error ) . toContain ( "Invalid patch_format" ) ;
631+ expect ( mockAppendSafeOutput ) . not . toHaveBeenCalled ( ) ;
632+ } ) ;
612633 } ) ;
613634
614635 describe ( "pushToPullRequestBranchHandler" , ( ) => {
@@ -818,12 +839,31 @@ describe("safe_outputs_handlers", () => {
818839 const responseData = JSON . parse ( result . content [ 0 ] . text ) ;
819840 expect ( responseData . result ) . toBe ( "error" ) ;
820841 expect ( responseData . error ) . toContain ( "Invalid patch_format" ) ;
821- expect ( responseData . error ) . toContain ( "invalid-format" ) ;
822842 expect ( responseData . error ) . toContain ( "am" ) ;
823843 expect ( responseData . error ) . toContain ( "bundle" ) ;
844+ // Must not echo the raw resolved value (could be a secret expression result)
845+ expect ( responseData . error ) . not . toContain ( "invalid-format" ) ;
824846 // Must not have appended any safe output
825847 expect ( mockAppendSafeOutput ) . not . toHaveBeenCalled ( ) ;
826848 } ) ;
849+
850+ it ( "should fail closed when patch_format resolves to an empty string" , async ( ) => {
851+ handlers = createHandlers ( mockServer , mockAppendSafeOutput , {
852+ push_to_pull_request_branch : {
853+ patch_format : "" ,
854+ } ,
855+ } ) ;
856+
857+ const result = await handlers . pushToPullRequestBranchHandler ( {
858+ branch : "feature-branch" ,
859+ } ) ;
860+
861+ expect ( result . isError ) . toBe ( true ) ;
862+ const responseData = JSON . parse ( result . content [ 0 ] . text ) ;
863+ expect ( responseData . result ) . toBe ( "error" ) ;
864+ expect ( responseData . error ) . toContain ( "Invalid patch_format" ) ;
865+ expect ( mockAppendSafeOutput ) . not . toHaveBeenCalled ( ) ;
866+ } ) ;
827867 } ) ;
828868
829869 describe ( "handler structure" , ( ) => {
0 commit comments