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

Validate dependencies and incompatibilities #91

Conversation

ithinkandicode
Copy link
Collaborator

Validates dependencies and incompatibilities, checking the following for any specified mod IDs:

Closes #23

@ithinkandicode ithinkandicode linked an issue Feb 4, 2023 that may be closed by this pull request
@ithinkandicode ithinkandicode changed the title Validate dependencies and incompatibilities (closes #23) Validate dependencies and incompatibilities Feb 4, 2023
addons/mod_loader/mod_manifest.gd Outdated Show resolved Hide resolved
addons/mod_loader/mod_manifest.gd Outdated Show resolved Hide resolved
var intro_text = "A %s for the mod '%s' is invalid: " % [type, original_mod_id]

# contains hyphen?
if not check_mod_id.count("-") == 1:
Copy link
Collaborator

Choose a reason for hiding this comment

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

you could use the is_name_or_namespace_valid func if you String.split("-") here (and checked if the array length is exactly 2)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried this originally, but it wasn't nearly as helpful. Here's the error if I use is_name_or_namespace_valid:

error-ste

And here's the error message with the approach I've used:

error-current

The 1st error tells you something is wrong with either a name or a namespace, but gives no indication of where/how to fix the problem. You don't know if it's occurring in your own mod or a dependency of it, nor whether it's an issue with the mods own name, or a dependency, or an incompatibility.

Whereas the 2nd error tells you which mod has an issue, and exactly where the issue is.

Trying to use is_name_or_namespace_valid initially is actually the reason I made my errors so explicitly helpful: When I was testing this I made a bunch of purposefully faulty manifests, but found that I had no idea which of them were incorrect.

Better to do as much as we can to help people fix issues like this IMO.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, you are right. Then it might be a better idea to turn the log in is_name_or_namespace_valid into an error and add the log fatal like you did here once it returns false. I think that avoids having two places for id validation and the logs are still as informative, right? And don't forget to check false and log fatal after the other uses of it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe that would be better in a subsequent PR? I don't want to change anything beyond the scope of validating deps/incompats for this one

Copy link
Collaborator

Choose a reason for hiding this comment

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

to get it done with I suppose. Having two places for the same validation is not good though, that needs to change

addons/mod_loader/mod_manifest.gd Outdated Show resolved Hide resolved
@ithinkandicode ithinkandicode added the validation Feature to make things safe and predictable label Feb 5, 2023
Copy link
Collaborator

@Qubus0 Qubus0 left a comment

Choose a reason for hiding this comment

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

let's do the subsequent pr

@ithinkandicode ithinkandicode merged commit 3decb33 into GodotModding:develop Feb 5, 2023
@ithinkandicode ithinkandicode deleted the validate-dependencies-and-incompatibilities branch February 5, 2023 10:34
@KANAjetzt KANAjetzt mentioned this pull request Feb 15, 2023
This was referenced Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation Feature to make things safe and predictable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependencies and incompatibilities can accept invalid mod IDs
2 participants