@@ -390,6 +390,26 @@ describe("installSignalCliFromRelease", () => {
390390 expect ( fetchResult . release ) . toHaveBeenCalledTimes ( 1 ) ;
391391 } ) ;
392392
393+ it . each ( [
394+ [ "null" , "null" ] ,
395+ [ "array" , "[]" ] ,
396+ [ "non-string tag_name" , JSON . stringify ( { tag_name : 123 , assets : [ ] } ) ] ,
397+ [ "non-array assets" , JSON . stringify ( { tag_name : "v0.14.6" , assets : { } } ) ] ,
398+ ] ) ( "returns an installer error for a valid JSON %s payload" , async ( _kind , body ) => {
399+ const fetchResult = okDownloadResponse ( body , {
400+ headers : { "content-type" : "application/json" } ,
401+ } ) ;
402+ fetchWithSsrFGuardMock . mockResolvedValue ( fetchResult ) ;
403+
404+ const result = await installSignalCliFromRelease ( { log : vi . fn ( ) } as unknown as RuntimeEnv ) ;
405+
406+ expect ( result ) . toEqual ( {
407+ ok : false ,
408+ error : "Failed to parse signal-cli release info." ,
409+ } ) ;
410+ expect ( fetchResult . release ) . toHaveBeenCalledTimes ( 1 ) ;
411+ } ) ;
412+
393413 it ( "bounds oversized GitHub release metadata and cancels the stream" , async ( ) => {
394414 const chunkSize = 1024 * 1024 ;
395415 const chunkCount = 20 ; // 20 MiB — over the 16 MiB cap
@@ -517,13 +537,16 @@ describe("installSignalCliFromRelease", () => {
517537 }
518538 } ) ;
519539
520- it ( "removes the download temp dir when the download throws " , async ( ) => {
540+ it ( "skips malformed asset rows while retaining a valid download " , async ( ) => {
521541 setProcessPlatform ( "linux" , "x64" ) ;
522542 fetchWithSsrFGuardMock . mockResolvedValueOnce (
523543 okDownloadResponse (
524544 JSON . stringify ( {
525545 tag_name : "v0.0.0-download-failure-test" ,
526546 assets : [
547+ null ,
548+ { name : 42 , browser_download_url : "https://example.com/wrong-name.tar.gz" } ,
549+ { name : "signal-cli-wrong-url.tar.gz" , browser_download_url : false } ,
527550 {
528551 name : "signal-cli-0.0.0-Linux-native.tar.gz" ,
529552 browser_download_url : "https://example.com/linux-native.tar.gz" ,
@@ -539,6 +562,10 @@ describe("installSignalCliFromRelease", () => {
539562 installSignalCliFromRelease ( { log : vi . fn ( ) } as unknown as RuntimeEnv ) ,
540563 ) . rejects . toThrow ( "download failed" ) ;
541564
565+ expect ( fetchWithSsrFGuardMock ) . toHaveBeenNthCalledWith (
566+ 2 ,
567+ expect . objectContaining ( { url : "https://example.com/linux-native.tar.gz" } ) ,
568+ ) ;
542569 await expectTempDownloadDirMissing ( ) ;
543570 } ) ;
544571} ) ;
0 commit comments