Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parseShardedIndex validation error, cap maximum sharded json file #491

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

Kakulukian
Copy link
Member

No description provided.

@Kakulukian Kakulukian marked this pull request as ready for review February 20, 2024 14:30
Copy link
Member

@coyotte508 coyotte508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly more efficient alternative is to rely on the content-length header of the response

Since the fetch is in two stages:

  • get the headers
  • download the content

So if we check the content-length between the two stages, we don't have to download any data (and don't need to rely on the range)

@Kakulukian Kakulukian merged commit fee1c6b into main Feb 20, 2024
2 checks passed
@Kakulukian Kakulukian deleted the fix-parseShardedIndex-invalid-json branch February 20, 2024 14:46
});

if (!indexResp) {
throw new SafetensorParseError(`Failed to parse file ${path}: failed to fetch safetensors index.`);
}

// no validation for now, we assume it's a valid IndexJson.
const index: SafetensorsIndexJson = await indexResp.json();
let index: SafetensorsIndexJson;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment one line above then?

Copy link
Member Author

@Kakulukian Kakulukian Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still true we don't enforce any validation on the payload except being a JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants