fix(upgrade): skip Modrinth versions with empty files#516
Open
SAY-5 wants to merge 1 commit into
Open
Conversation
A Modrinth project version can have an empty files array (some legacy/broken entries on the API). from_mr_version then calls VersionExt::get_version_file which indexes self.files[0] and panics with 'index out of bounds: the len is 0 but the index is 0'. Filter empty-files versions out of the version list before mapping, so they are silently skipped instead of crashing ferium-worker. Fixes gorilla-devs#514
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #514.
Problem
When
ferium upgradefetches the Modrinth version list for a project, some legacy/broken entries can come back with an emptyfilesarray (e.g. EasyAuth, Silk in the issue thread).from_mr_versionthen callsVersionExt::get_version_file, which does.unwrap_or(&self.files[0])and panics:Fix
Filter empty-files versions out of
version_list()results inmod_downloadable.rsbefore mapping withfrom_mr_version. They are skipped the same way they would be if no version satisfied the filters, instead of crashing the worker.Mirrors the no-files-available handling added for Modrinth modpacks in #508.
Testing
cargo build -p libium --libandcargo clippy -p libium --lib --no-deps -- -D warningspass cleanly.cargo test -p libium --libruns (no existing unit tests in libium).