Fix duplicate key exception in CompatibilitySorter #3908
Merged
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.
Problem
The metadata validator threw a duplicate key exception while checking KSP-CKAN/NetKAN#9800:
https://github.com/KSP-CKAN/NetKAN/actions/runs/6207962451/job/16853654203?pr=9800
Cause
The
CompatibilitySorter
from #2963 was updated to handle multiple source repos in #3904, but multipleAvailableModule
s with the same identifier weren't covered. This is essential for the metadata validator.Changes
AvailableModules
with the same identifier, theCompatibilitySorter
merges them into one newAvailableModule
containing the combined list ofCkanModule
s; if there are multipleCkanModule
s with the same identifier and version, the module from the higher priority repo (defined as higher up in the list, so a lower number) takes precedenceAvailableModule.Remove
wasn't being used and is deletedAvailableModule.Add
is only being used internally so is now privateWe may have to update the metadata validator after this to set the priority of the repositories to get the right modules to load; I think we were previously skating by on the coincidence that
default
comes beforelocal
alphabetically.