octokit / rest.js

GitHub REST API client for JavaScript

Home Page:https://octokit.github.io/rest.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: Extra "/" in API call generated by createComment method

jpilowsk-te opened this issue · comments

What happened?

Here is the error. The URL has an extra forward slash ("/") in the url, before the repo name.

Versions

Octokit.js v1.22.19, Node v18.17.0

Relevant log output

comment for <my-repo>
RequestError [HttpError]: Not Found
    at /Users/jpilowsk/workspace/<private>/<backstage>/node_modules/@octokit/request/dist-node/index.js:112:21
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  status: 404,
  response: {
    url: 'https://api.github.com/repos//<my-repo>/issues/<my-pr>/comments',
    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',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Thu, 02 Nov 2023 03:26:37 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-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': 'F86E:28A5:C918AF:CF8F6A:654316ED',
      'x-oauth-scopes': 'read:discussion, read:org, read:user, repo, user:email',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4996',
      'x-ratelimit-reset': '1698899196',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '4',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Not Found',
      documentation_url: 'https://docs.github.com/rest'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos//<my-repo>/issues/<my-pr-number>/comments',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/20.0.1 octokit-core.js/5.0.0 Node.js/18.17.0 (darwin; arm64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"body":"Some comment"}',
    request: { hook: [Function: bound bound register] }
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

Looking at the API function, I was missing the owner field. That's what the problem was.