pozil / auto-assign-issue

GitHub Action that auto-assigns issues or PRs to one or more users
Creative Commons Zero v1.0 Universal
52 stars 27 forks source link

Permit self-assign on PR #121

Open klassenserver7b opened 1 month ago

klassenserver7b commented 1 month ago

I use your action on my project, but when I make a PR, it tries to request a review from me. This is obviously prohibited, as you mention in the annotation to allowSelfAssign-parameter (This flag is ignored when working with PRs as self assigning a PR for review is forbidden by GitHub.) But especially if you ignore this flag, there should be some logic prohibiting my self assignment.

Context: The repo is created by me in an organization created by me.

My runner log:

Run pozil/auto-assign-issue@v1
  with:
    repo-token: ***
    assignees: OTHER1, OTHER2, ME
    numOfAssignee: 2
    allowSelfAssign: false
    abortIfPreviousAssignees: false
    removePreviousAssignees: false
    allowNoAssignees: false
    teamIsPullRequestReviewer: false
Setting assignees for PR 5: ["ME","OTHER1"]
Setting reviewers for PR 5: ["ME","OTHER1"]
/home/runner/work/_actions/pozil/auto-assign-issue/v1/node_modules/@octokit/request/dist-node/index.js:124
      const error = new import_request_error.RequestError(toErrorMessage(data), status, {
                    ^

RequestError [HttpError]: Review cannot be requested from pull request author. - https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request
    at /home/runner/work/_actions/pozil/auto-assign-issue/v1/node_modules/@octokit/request/dist-node/index.js:124:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runAction (/home/runner/work/_actions/pozil/auto-assign-issue/v1/src/action.js:167:17) {
  status: 422,
  response: {
    url: 'https://api.github.com/repos/MY_ORG/MY_PROJECT/pulls/5/requested_reviewers',
    status: 422,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      'content-length': '176',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Thu, 09 May 2024 23:11:14 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-github-permissions': 'pull_requests=write',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '1381:234F8F:CCF1DA:142724B:663D5811',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4977',
      'x-ratelimit-reset': '1715298634',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '23',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Review cannot be requested from pull request author.',
      documentation_url: 'https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/MY_ORG/MY_PROJECT/pulls/5/requested_reviewers',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-core.js/5.1.0 Node.js/16.20.2 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"reviewers":["ME","OTHER1"]}',
    request: {
      agent: Agent {
        _events: [Object: null prototype] {
          free: [Function (anonymous)],
          newListener: [Function: maybeEnableKeylog]
        },
        _eventsCount: 2,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object: null prototype] {
          keepAlive: false,
          maxSockets: 100,
          path: null
        },
        requests: [Object: null prototype] {},
        sockets: [Object: null prototype] {},
        freeSockets: [Object: null prototype] {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: 100,
        maxFreeSockets: 256,
        scheduling: 'lifo',
        maxTotalSockets: Infinity,
        totalSocketCount: 0,
        maxCachedSessions: 100,
        _sessionCache: { map: {}, list: [] },
        [Symbol(kCapture)]: false
      },
      fetch: [Function: proxyFetch],
      hook: [Function: bound bound register]
    }
  }
}
pozil commented 1 month ago

Hi @klassenserver7b, thanks for reaching out.

I have already put in place some checks and related tests that are meant to prevent this from happening so I wonder how this happened in your case. My guess is that the action is not able to identify you as the author of the PR. Is there something specific about this PR or the workflow setup that could explain why it's behaving this way?

klassenserver7b commented 1 month ago

I have no clue because I opened the PR manually on github.com. The login name should definitely be no problem that way. I may investigate this further and reach out again.

pozil commented 1 month ago

I just tried once more with similar settings but I couldn't reproduce:

Run pozil/auto-assign-issue@v1
  with:
    assignees: pozil, other1, other2
    allowSelfAssign: true
    abortIfPreviousAssignees: false
    removePreviousAssignees: false
    allowNoAssignees: false
    teamIsPullRequestReviewer: false
    repo-token: ***
Setting assignees for PR 11: ["pozil","other1","other2"]
Setting reviewers for PR 11: ["other1","other2"]

The action fails because other1 and other2 are not real users but the point is that I'm removed from the list of reviewers as expected...