-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[MNG-7375] prevent potential NPE in Metadata.merge(...) #645
Conversation
This PR hides the fact that the input data is invalid. Obviously, we need a |
So how should the merge deal with a missing prefix? Throw an ISE or IAE? Where would the validator be hooked in? |
I see two issues:
for the metadata, but we don't :-( |
Both issues are correct but are rather follow-ups to MNG-7375. My question is about how to deal with a missing prefix within |
The validator would fail the build with an appropriate error message before anything being merged. I.e., source and target are validated upfront before merge happens. |
I don't have access to the NEXUS issue :-( |
As I cannot change the security level of https://issues.sonatype.org/browse/NEXUS-30749 (Sonatype change the default to private unfortunately) I also attached the PDF export to https://issues.apache.org/jira/browse/MNG-7375 |
bc03b17
to
2a33eff
Compare
@michael-o I now added a first draft of a MetadataValidator (inspired by SettingsValidator). Please tell me what you think! |
@kwin Insane! Please open a new JIRA issue for this. I am thinking whether we can introduce this in 3.8.x or must wait at least until 3.9.x. We have a lot of talks about validators with @rfscholte last year. He should be part of this discussion as well. |
Metadata is only partially handled inside Maven (core), mostly it is now handled transparently in Maven Resolver, so probably the validator should be part of Maven Resolver and only for some places where Maven directly leverages metadata it should be reused inside Maven directly. WDYT? Update: As the validation is Maven repository specific it needs to be called from maven-resolver-provider which is in fact part of the Maven main reactor. I added validation calls in all metadata reads from all Maven modules except the legacy "maven-compat". |
2e18fe8
to
f8181f0
Compare
@cstamas What is your opinion on the package of this new solution? I don't have one yet. |
"handled transparently" is the key here. IMO, any validation should be next where model is, in Maven and not in Resolver, as with any other maven-specific models, Resolver have no clue about them (so resolver have no clue to parse XML into Metadata). Moreover, Resolver has no maven-specific bits, while Metadata is maven-specific bit, so IMHO it should NOT go into Resolver. OTOH, I'd -1 on "componentizing" maven-repository-metadata, as I'd keep same separation as with "model": -model, model-builder/validator etc. So, IMO maven-repository-metadata getting added components is wrong IMHO. Will check the rest a bit later. |
Any suggestion where to add the default validation module then, because as you say "any validation should be next where model is"? |
I support @cstamas position.
Likely like POM model or settings model. Introduce a |
Agreed, while in case of metadata this may seem like overkill, I still like the separation of models and logic around them (aka builder or validator or whatnot). Ultimately, I'd like to see models moved out of maven, as they anyway barely change. Yes, we expect a bit of turbulence in upcoming maven (plans), but still, the amount of changes to models as compared to maven core etc is more like 0 to million... |
Correct, we pointlessly waste cycles for their generation. This applies to a lot of stuff we do. |
Done in d39be11. |
Good question, I will come back to this as soon as I have completed my open votes. |
@michael-o Any update here? |
No, not yet. Ping me in a week. |
Is this one still relevant regarding the changes done in MPLUGIN? |
Yes, as in general metadata should be validated. This is about exposing useful error messages in case the metadata is invalid. |
Alright. Will check later. |
Do you see this for 3.8.x as well? |
Just for 4.x for now. |
Add unit tests for merge
call validators when dealing with metadata
"maven-repository-metadata-builder"
d39be11
to
cb9333e
Compare
@kwin I've rebased the PR to fix all conflicts, I haven't done an in-depth review yet, but I wonder about adding yet another module for basically a single service. I also wonder if we could implement this service natively for the v4 api: so the service interface in |
Introducing a new module was suggested in #645 (comment), but I am fine with the original approach as well (impl in existing module). |
Consider backporting this to Maven 3.x; otherwise, maven-plugin-plugin version 3.13.0 cannot be used. What is the updated status of this PR? |
Unsure what is there to backport here? All the affected code is deprecated, so IMHO should be just left as is. Why is m-p-p 3.13.0 unusable with Maven 3? |
@cstamas Apologies. I should have linked to the related issue: https://issues.apache.org/jira/browse/MNG-8121 nexus-staging-maven-plugin works in version 3.12.0 but breaks in 3.13.0. |
Add unit tests for merge
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MNG-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MNG-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.