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

error for nonexistent --pr is unhelpful #39

Open
ljharb opened this issue Jan 1, 2022 · 4 comments
Open

error for nonexistent --pr is unhelpful #39

ljharb opened this issue Jan 1, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted PRs are welcome!

Comments

@ljharb
Copy link
Owner

ljharb commented Jan 1, 2022

When I run can-merge -p 3133 on a repo where the PR does exist, but under a non-origin remote, I get this:

$CAN_MERGE_PATH/node_modules/@octokit/graphql/dist-node/index.js:81
      throw new GraphqlResponseError(requestOptions, headers, response.data);
            ^

GraphqlResponseError: Request failed due to following response errors:
 - Could not resolve to a PullRequest with the number of 3133.
    at $CAN_MERGE_PATH/node_modules/@octokit/graphql/dist-node/index.js:81:13
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runQuery ($CAN_MERGE_PATH/utils/runQuery.js:9:19) {
  request: {
    query: '\n' +
      '      {\n' +
      '        repository(owner: "ljharb", name: "eslint-plugin-react") {\n' +
      '          branchProtectionRules(first: 10) {\n' +
      '            nodes {\n' +
      '              requiresStatusChecks\n' +
      '              requiredApprovingReviewCount\n' +
      '              requiredStatusCheckContexts\n' +
      '            }\n' +
      '          }\n' +
      '          pullRequest(number: 3133) {\n' +
      '            \n' +
      '        state\n' +
      '        url\n' +
      '        title\n' +
      '        number\n' +
      '        merged\n' +
      '        mergeable\n' +
      '        reviewDecision\n' +
      '        potentialMergeCommit {\n' +
      '          commitUrl\n' +
      '        }\n' +
      '        commits(last: 1) {\n' +
      '          nodes {\n' +
      '            commit {\n' +
      '              statusCheckRollup {\n' +
      '                state\n' +
      '                contexts(last: 100) {\n' +
      '                  totalCount\n' +
      '                  pageInfo {\n' +
      '                    endCursor\n' +
      '                    hasNextPage\n' +
      '                  }\n' +
      '                  nodes {\n' +
      '                    __typename\n' +
      '                    ... on CheckRun {\n' +
      '                      status\n' +
      '                      name\n' +
      '                      conclusion\n' +
      '                    }\n' +
      '                    ... on StatusContext {\n' +
      '                      state\n' +
      '                      context\n' +
      '                      description\n' +
      '                    }\n' +
      '                  }\n' +
      '                }\n' +
      '              }\n' +
      '            }\n' +
      '          }\n' +
      '        }\n' +
      '\n' +
      '          }\n' +
      '        }\n' +
      '        rateLimit {\n' +
      '          cost\n' +
      '          remaining\n' +
      '        }\n' +
      '      }\n' +
      '    ',
    headers: { authorization: 'token $token' }
  },
  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',
    connection: 'close',
    'content-encoding': 'gzip',
    'content-security-policy': "default-src 'none'",
    'content-type': 'application/json; charset=utf-8',
    date: 'Sat, 01 Jan 2022 17:41:05 GMT',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: 'GitHub.com',
    'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
    'transfer-encoding': 'chunked',
    vary: 'Accept-Encoding, Accept, X-Requested-With',
    'x-accepted-oauth-scopes': 'repo',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': 'E4D5:8B71:3BF308F:3EE5D8C:61D09231',
    'x-oauth-scopes': 'read:discussion, read:enterprise, read:gpg_key, read:org, read:packages, read:public_key, read:repo_hook, read:user, repo, user:email, user:follow',
    'x-ratelimit-limit': '5000',
    'x-ratelimit-remaining': '4998',
    'x-ratelimit-reset': '1641062456',
    'x-ratelimit-resource': 'graphql',
    'x-ratelimit-used': '2',
    'x-xss-protection': '0'
  },
  response: {
    data: {
      repository: { branchProtectionRules: { nodes: [] }, pullRequest: null },
      rateLimit: { cost: 1, remaining: 4998 }
    },
    errors: [
      {
        type: 'NOT_FOUND',
        path: [ 'repository', 'pullRequest' ],
        locations: [ { line: 11, column: 11 } ],
        message: 'Could not resolve to a PullRequest with the number of 3133.'
      }
    ]
  },
  errors: [
    {
      type: 'NOT_FOUND',
      path: [ 'repository', 'pullRequest' ],
      locations: [ { line: 11, column: 11 } ],
      message: 'Could not resolve to a PullRequest with the number of 3133.'
    }
  ],
  data: {
    repository: { branchProtectionRules: { nodes: [] }, pullRequest: null },
    rateLimit: { cost: 1, remaining: 4998 }
  }
}

Node.js v17.3.0

This seems like something we could catch specifically and display a helpful error message like "PR X was not found, perhaps it's on a different remote, here's how you can specify that"?

@ljharb ljharb added enhancement New feature or request good first issue Good for newcomers help wanted PRs are welcome! labels Jan 1, 2022
@Green-Ranger11
Copy link
Collaborator

After what I'm currently working on (#37) I was thinking of working on #33 and maybe that could be worked on in conjunction with this. So when the error is "Could not resolve to a PullRequest ..." we could display a helpful message.
One question I have is:
Should it always display or only when the remote is different from origin?

@ljharb
Copy link
Owner Author

ljharb commented Jan 1, 2022

The --remote suggestion should only display when there's a remote present whose name is not origin :-) The nicer error message about "we couldn't find a PR" should always display.

@abdumamdouh
Copy link
Contributor

Hello! I'm still exploring the project, feels like I can start working on this after exploring the codebase. Is the issue available?

@ljharb
Copy link
Owner Author

ljharb commented Feb 10, 2022

Yup, go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted PRs are welcome!
Projects
None yet
Development

No branches or pull requests

4 participants