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

Method listLabelsOnIssue ignore "issue_number" and 404 #1842

Open
QJoly opened this issue Jun 30, 2023 · 1 comment
Open

Method listLabelsOnIssue ignore "issue_number" and 404 #1842

QJoly opened this issue Jun 30, 2023 · 1 comment

Comments

@QJoly
Copy link

QJoly commented Jun 30, 2023

Bug Report

Current Behavior

Here is my code:

async function isLabelPresent(context, label) {
  const issue_number = context.payload.issue.number
  const owner = context.payload.repository.owner.login
  const repo = context.payload.repository.name

  console.log(`isLabelPresent : ${owner}/${repo}#${issue_number} `)

  const labels = await context.octokit.issues.listLabelsOnIssue({
    owner: owner,
    repo: repo,
    issue_number: issue_number
  })

  for (let i = 0; i < labels.data.length; i++) {
    if (labels.data[i].name === label) {
      console.log("Label " + label + " is already set")
      return true;
    }
  }
  console.log("Label " + label + " is not set")
  return false;
}

As soon as I call "listLabelsOnIssue", I get a 404 error because the variable issue_number is not used. However, the console.log shows me the owner, the repo and the issue_number (ex: isLabelPresent: RubxKube/charts#4).

RequestError [HttpError]: Not Found
    at /home/kiko/Documents/RubxKube/markdownify/node_modules/probot/node_modules/@octokit/request/dist-node/index.js:86:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async sendRequestWithRetries (/home/kiko/Documents/RubxKube/markdownify/node_modules/@octokit/auth-app/dist-node/index.js:398:12)
    at async Job.doExecute (/home/kiko/Documents/RubxKube/markdownify/node_modules/bottleneck/light.js:405:18) {
  status: 404,
  response: {
    url: 'https://api.github.com/repos/RubxKube/charts/issues//labels',
    status: 404,
    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: 'Fri, 30 Jun 2023 20:26:44 GMT',
...

Expected behavior/code

I'd like to check if a label is setted or not on a pull request. My function should be return True or False.

Environment

  • Probot version(s): 12.3.1
  • Node/npm version: Node.js v18.16.1
  • OS: Pop OS

Possible Solution

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@welcome
Copy link

welcome bot commented Jun 30, 2023

Thanks for opening this issue. A contributor should be by to give feedback soon. In the meantime, please check out the contributing guidelines and explore other ways you can get involved.

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

No branches or pull requests

1 participant