@@ -150,24 +150,27 @@ func FindBestAsset(assets []CommonAsset, platform Platform, toolName string) (*C
150150}
151151
152152// FetchAndParseChecksumFile downloads and parses a checksum file from a URL.
153- func FetchAndParseChecksumFile (ctx context.Context , client * http.Client , url string ) map [string ]string {
153+ func FetchAndParseChecksumFile (ctx context.Context , client * http.Client , url string ) ( map [string ]string , error ) {
154154 req , err := http .NewRequestWithContext (ctx , "GET" , url , nil )
155155 if err != nil {
156- return nil
156+ return nil , err
157157 }
158158 resp , err := client .Do (req )
159159 if err != nil {
160- return nil
160+ return nil , err
161161 }
162162 defer resp .Body .Close ()
163163
164+ if resp .StatusCode == http .StatusNotFound {
165+ return nil , nil
166+ }
164167 if resp .StatusCode != http .StatusOK {
165- return nil
168+ return nil , fmt . Errorf ( "failed to fetch checksum file: HTTP %d" , resp . StatusCode )
166169 }
167170
168171 body , err := io .ReadAll (resp .Body )
169172 if err != nil {
170- return nil
173+ return nil , err
171174 }
172175
173176 checksums := make (map [string ]string )
@@ -189,13 +192,13 @@ func FetchAndParseChecksumFile(ctx context.Context, client *http.Client, url str
189192 }
190193 }
191194
192- return checksums
195+ return checksums , nil
193196}
194197
195198// FindChecksumForAsset attempts to find a matching checksum for an asset from a list of all assets.
196- func FindChecksumForAsset (ctx context.Context , client * http.Client , assets []CommonAsset , targetAsset * CommonAsset ) string {
199+ func FindChecksumForAsset (ctx context.Context , client * http.Client , assets []CommonAsset , targetAsset * CommonAsset ) ( string , error ) {
197200 if targetAsset == nil {
198- return ""
201+ return "" , nil
199202 }
200203
201204 // 1. Look for a checksum file
@@ -212,16 +215,19 @@ func FindChecksumForAsset(ctx context.Context, client *http.Client, assets []Com
212215 }
213216
214217 if checksumAsset != nil {
215- checksumMap := FetchAndParseChecksumFile (ctx , client , checksumAsset .URL )
218+ checksumMap , err := FetchAndParseChecksumFile (ctx , client , checksumAsset .URL )
219+ if err != nil {
220+ return "" , err
221+ }
216222 if checksumMap != nil {
217223 // Try exact match first
218224 if c , ok := checksumMap [targetAsset .Name ]; ok {
219- return c
225+ return c , nil
220226 }
221227 }
222228 }
223229
224- return ""
230+ return "" , nil
225231}
226232
227233// FindGPGSignatureForAsset attempts to find a matching GPG signature for an asset.
@@ -333,7 +339,10 @@ func GenericGetDownloadInfo(ctx context.Context, p HostingProvider, tool string,
333339 return nil , NewBackendError (p .Name (), tool , "no matching asset" , nil )
334340 }
335341
336- checksum := FindChecksumForAsset (ctx , p .GetClient (), release .Assets , bestAsset )
342+ checksum , err := FindChecksumForAsset (ctx , p .GetClient (), release .Assets , bestAsset )
343+ if err != nil {
344+ return nil , NewBackendError (p .Name (), tool , "failed to fetch checksum file" , err )
345+ }
337346 gpgSigURL := FindGPGSignatureForAsset (release .Assets , bestAsset )
338347
339348 return & VersionInfo {
0 commit comments