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

Bug in QnByArchitect.understand(...) #1105

Open
amihaiemil opened this issue May 25, 2016 · 32 comments
Open

Bug in QnByArchitect.understand(...) #1105

amihaiemil opened this issue May 25, 2016 · 32 comments
Labels

Comments

@amihaiemil
Copy link

amihaiemil commented May 25, 2016

In method QnByArchitect.understand(...), the decision wether rultor understands the request or asks the architect to confirm is based on boolean legal which is determined like this:

final boolean legal = logins.isEmpty()
            || logins.contains(
                comment.author().login().toLowerCase(Locale.ENGLISH)
            )
            || logins.contains(
                issue.author().login().toLowerCase(Locale.ENGLISH)
            );

where logins (btw, I would name it architects), contains the architects' logins.

This means that if an architect makes a PR (maybe he wants to have it in history of merges and not make the commit directly on master) or any other kind of issue, I can go and give commands to rultor and it will process them.

This is because the conditions above translate to false, false, true - there are architects declared for the project; the comment author is not an architect, but the issue author is an architect.

I tested this with the following unit test, which fails:

    @Test
    public void rejectsIfNotArchitect() throws Exception {
        final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
        final Repo repoJeff = new MkGithub(storage, "jeff").randomRepo();
        final Issue issue = repoJeff.issues().create("", "");

        final Github amihaiemil = new MkGithub(storage, "amihaiemil");
        Repo repoMihai = amihaiemil.repos().get(repoJeff.coordinates());
        Issue issueMihai = repoMihai.issues().get(issue.number());
        final Comment.Smart mihaiComment = new Comment.Smart(
            issueMihai.comments().post("deploy")
        );

        final Question question = Mockito.mock(Question.class);
        final URI home = new URI("#");
        new QnByArchitect(
            new Profile.Fixed(
                new XMLDocument("<p><entry key='a'>jeff</entry></p>")
            ),
            "/p/entry[@key='a']/text()", question
        ).understand(mihaiComment, home);
        Mockito.verify(question, Mockito.never()).understand(mihaiComment, home);
        MatcherAssert.assertThat(
            issue.comments().iterate(),
            Matchers.<Comment>iterableWithSize(2)
        );
    }

Notice that Jeff is both issue author and project architect and amihaiemil gives the command to rultor.

Fix:
remove the condition

logins.contains(
    issue.author().login().toLowerCase(Locale.ENGLISH)
);

After the bug is fixed it would also be nice to add this unit test to QnByArchitectTest

@amihaiemil
Copy link
Author

@alex-palevsky I think this issue is pretty urgent.

@amihaiemil
Copy link
Author

@alex-palevsky @original-brownbear I made PR #1106 for this issue.

@amihaiemil
Copy link
Author

@alex-palevsky ping

@original-brownbear
Copy link
Contributor

@amihaiemil I'm aware of the PR/Issue, will review shortly. Sorry many things going on right now, but this is on the radar for today for me :)

@amihaiemil
Copy link
Author

@original-brownbear sure, thanks : )

@original-brownbear
Copy link
Contributor

@amihaiemil I think this is the intended behaviour but I may be misunderstanding the issue.

From what I understand you criticise the face that this happens:

  1. Architect makes PR.
  2. Commander ( or is it arbitrary person and not commander ) calls merge
  3. Rultor merges without confirmation.

I think if its commanders only in step two this is not a bug right ? At least I did always take this for the intended behaviour. Or do you see an issue with this ?

@amihaiemil
Copy link
Author

@original-brownbear If you test the method in isolation (see unit test), then it can be anyone in step 2, not just commanders. I dont know the whole code yet, maybe there's a layer on top of it which only lets commanders talk to rultor. But even if it lets just commanders, it looks a bit inconsistent to me, since the same commander, with the same command needs approval on other issues that are not authored by the architect. We can test this easily if you make a small pr, i would say "merge" and see how it acts.

@amihaiemil
Copy link
Author

@original-brownbear as you can see, in PR #1107 I told rultor to merge and he asked you to confirm it, which means the method here was called with my Profile; If you were the PRs author it would have merged, exactly like the unit test.

@amihaiemil
Copy link
Author

@original-brownbear it's also not called somewhere else in the code. Simply search the repo for the string "QnByArchitect.denied" (the key of the message from phrases_en_US.properties )and you will see it's only used in the method in cause.

@amihaiemil
Copy link
Author

@original-brownbear from my point of view this bug is confirmed :)

@original-brownbear
Copy link
Contributor

@amihaiemil yea you're right. Also this at least extends to the stop command as I could now observe in a different project.
Sorry for the delays with me btw, normal operations on my end will resume within 12-16h!

@original-brownbear
Copy link
Contributor

@alex-palevsky valid bug.

@amihaiemil
Copy link
Author

@original-brownbear Can this also be assigned to me since I made a PR with the fix? (I'm not sure if I can be both author and resolver)

@alex-palevsky
Copy link
Contributor

@alex-palevsky valid bug.

@original-brownbear added "bug" tag to this issue

@amihaiemil
Copy link
Author

amihaiemil commented May 30, 2016

@alex-palevsky assign me here please.

@alex-palevsky
Copy link
Contributor

@amihaiemil I set the milestone to 2.0 since there is nothing set yet

@alex-palevsky alex-palevsky added this to the 2.0 milestone May 30, 2016
@alex-palevsky
Copy link
Contributor

@amihaiemil thanks for tis bug, I topped your account for 15 mins, transaction AP-28280969RL475321G

@amihaiemil
Copy link
Author

@alex-palevsky assign me here please.

@alex-palevsky
Copy link
Contributor

@alex-palevsky @original-brownbear I made PR #1106 for this issue.

@amihaiemil thanks

@amihaiemil
Copy link
Author

@original-brownbear can I have this assigned to me?

@original-brownbear
Copy link
Contributor

@amihaiemil let me find out, you're not on the Rultor team so I need to ask first :) see below in a sec.

@original-brownbear
Copy link
Contributor

@yegor256 can I assign @amihaiemil here, despite him not being on the team? Seems he did some work towards fixing this already.

@amihaiemil
Copy link
Author

@yegor256 can you have a look here? Thanks

@amihaiemil
Copy link
Author

@yegor256 ping

@amihaiemil
Copy link
Author

@yegor256 ping

@yegor256
Copy link
Owner

@original-brownbear yes, you can, but keep in mind that it's a bad (very bad) practice to have the same person as a bug reporter and a bug fixer

@original-brownbear
Copy link
Contributor

@yegor256 yup, well see below anyhow.

@original-brownbear
Copy link
Contributor

@amihaiemil sorry not really as a result of @yegor256 's comment above alone, but more the fact that the PR does not fully resolve the issue ( and introduce a new one, will put the effort of explaining why that is so later ) + CR has not been assigned yet I'd rather postpone this one in favour of more pressing EC2 ones.

@original-brownbear
Copy link
Contributor

@alex-palevsky this is postponed.

@amihaiemil
Copy link
Author

@original-brownbear sure, no worries

@alex-palevsky
Copy link
Contributor

@alex-palevsky this is postponed.

@original-brownbear thanks, I added "postponed" label

@alex-palevsky
Copy link
Contributor

@alex-palevsky this is postponed.

@original-brownbear got it, someone else will be assigned soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants