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(
119
119
const indexResp = await downloadFile ( {
120
120
...params ,
121
121
path,
122
+ range : [ 0 , 10_000_000 ] ,
122
123
} ) ;
123
124
124
125
if ( ! indexResp ) {
125
126
throw new SafetensorParseError ( `Failed to parse file ${ path } : failed to fetch safetensors index.` ) ;
126
127
}
127
128
128
129
// 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
+ }
130
136
131
137
const filenames = [ ...new Set ( Object . values ( index . weight_map ) ) ] ;
132
138
const shardedMap : SafetensorsShardedHeaders = Object . fromEntries (
You can’t perform that action at this time.
0 commit comments