Warnings for missing swinfo.json deps #3827
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
See KSP-CKAN/KSP2-NetKAN#33, a dependency was missing from a KSP2 module. This dependency was documented (only) in the
swinfo.json
file, and the netkan didn't have it.This could easily happen again with other mods, either when initially adding them or as new versions are released.
Cause
The inflator parses the
swinfo.json
file but ignores itsdependencies
property. I thought about automatically importing it intoCkanModule.depends
, but that would have trapped us if:swinfo.json
was wrongChanges
Now when we inflate a module with a
swinfo.json
file, if it hasdependencies
listed, we'll check them and log a warning for any identifier that isn't in theCkanModule.depends
list. It's a warning instead of an error so a human can decide what to do.For now, min/max versions are ignored. From what I've seen, these tend to be filled in unnecessarily with non-useful data, so it would be a lot of noise / alert-fatigue to see these all if we logged them.
This way we will get a notification in Discord if a KSP2 module adds a new dependency and documents it in the
swinfo.json
file, or in the GitHub Action output in a pull request.Considered and not done
In principle, this code belongs in a
Validator
file/class.In practice, I started that and it got really messy. I had to duplicate essentially all of the logic of the
Transformer
class, including retrieving the file from the ZIP and checking the remote copy. The last straw was when I had to add anIGithubApi
object toCkanValidator
, which really does not belong there.Since I was ending up with an extended copy of the
Transformer
class, I thought it would be cleaner to extend the original. We can look into adding some sort of shared retrieval and caching forswinfo.json
data in the future and revisit this then.This means these warnings will only fire for
.netkan
files, not for validating.ckan
files. I think that's fine for now.