Skip modules with parse errors in deserialization #3347
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
Cause
v1.30.0 added the MPL-2.0 license in 85ac317, and KSP-CKAN/NetKAN#8343 indexed a mod that uses it. Our
License
class throws an exception when an unknown license is found, so 6de9c74 made sure thatspec_version
is v1.30 or higher when this license is used.Older clients will not be bothered by this as long as they are the only ones updating their own registries, because we skip modules with parsing errors during repo updates. However, if a newer client updates the registry, the module will be included, and there is no error handling for when we parse
registry.json
.Changes
Now
AvailableModule
uses theOnError
attribute to handle JSON parsing errors. It logs a warning, discards the affectedCkanModule
(happens automatically), and continues parsing. This allows CKAN to start even when it doesn't recognize a license in the saved registry.https://www.newtonsoft.com/json/help/html/SerializationErrorHandling.htm
Known limitations
This change won't affect installed modules. If your client is too old to parse modules that you've installed, you probably should be unable to start it.