lib/plugins: enforce one url per plugin#3674
lib/plugins: enforce one url per plugin#3674GaetanLepage merged 2 commits intonix-community:mainfrom
Conversation
bd56ed5 to
3d83df2
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This asserts that we don't accidentally end up with conflicting definitions. Such conflicts must be made explicit, e.g. using `mkForce` or `mkDefault`.
3d83df2 to
d1c122a
Compare
DataHearth
left a comment
There was a problem hiding this comment.
LGTM! Good feature to compact package definition👌
|
I like this, great work! |
Good suggestion. I initially had a more bespoke solution with errors along those lines, but I decided to leverage the module system's merge function instead. This strikes a balance between not needing to re-implement much logic vs having full control. Most of the error message comes from the module system, which is why it talks about options and definitions. The parts we can influence without re-writing the merge function are the "locations"; i.e. the "option path" and the "definition locations". I figured since this is likely to only be seen in new plugin PRs and in lockfile update PRs, the current error is fine. I did put some effort into getting sane locations for the definitions; e.g. the EDIT: maybe we could add some "error context" though? This would show up above the error in the stack trace as a "...while evaluation |
I've just tested this, and using The error gets thrown by the module system from another context, so wrapping I think the current solution is fine, but as always, if someone has ideas for how to improve it I'd welcome a PR. 😁 |
As per #3653 (comment)
We already assert that a URL is defined. Now we also asserts that multiple URLs are not defined.
As an example, this is what the errors typically look like: