ljharb/can-merge

error for nonexistent `--pr` is unhelpful

Open

#39 geöffnet am 1. Jan. 2022

Auf GitHub ansehen
 (4 Kommentare) (1 Reaktion) (2 zugewiesene Personen)JavaScript (3 Forks)github user discovery
enhancementgood first issuehelp wanted

Repository-Metriken

Stars
 (15 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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"?

Contributor Guide