File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -119,14 +119,20 @@ async function parseShardedIndex(
119119 const indexResp = await downloadFile ( {
120120 ...params ,
121121 path,
122+ range : [ 0 , 10_000_000 ] ,
122123 } ) ;
123124
124125 if ( ! indexResp ) {
125126 throw new SafetensorParseError ( `Failed to parse file ${ path } : failed to fetch safetensors index.` ) ;
126127 }
127128
128129 // no validation for now, we assume it's a valid IndexJson.
129- const index : SafetensorsIndexJson = await indexResp . json ( ) ;
130+ let index : SafetensorsIndexJson ;
131+ try {
132+ index = await indexResp . json ( ) ;
133+ } catch ( error ) {
134+ throw new SafetensorParseError ( `Failed to parse file ${ path } : not a valid JSON.` ) ;
135+ }
130136
131137 const filenames = [ ...new Set ( Object . values ( index . weight_map ) ) ] ;
132138 const shardedMap : SafetensorsShardedHeaders = Object . fromEntries (
You can’t perform that action at this time.
0 commit comments