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

[BUG]: types for octokit.rest.repos.createInOrg does not accept "internal" as visibility, despite it being valid #383

Open
1 task done
devjoes opened this issue Nov 17, 2023 · 4 comments
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@devjoes
Copy link

devjoes commented Nov 17, 2023

What happened?

I upgraded Octokit to version v20 of the API (by upgrading @actions/github to 6.0.0). This removed the internal option for visibility when calling octokit.rest.repos.createInOrg.
When trying to call this method with either of the remaining options public or private and creating a repo within an organisation I get the error You need admin access to the organization before adding a repository to it..
If I bypass type checking and forcibly set this option back to internal then it works. This leads me to believe that this is an issue with the generated types.d.ts (or rather the underlying OpenApi spec.)

This is the workaround - notice the cast to any

    await octokit.rest.repos.createInOrg({
      org: repoOrg,
      name: repoName,
      description: productRepoDescription,
      visibility: 'internal'
    } as any);

Versions

@actions/github: 6.0.0
@octokit/openapi-types: 19.0.2
typescript: 5.1.6
node: 20.7.0
npm: 10.1.0

Relevant log output

When using `private`

{
  status: 403,
  response: {
    url: 'https://api.github.com/orgs/REMOVED/repos',
    status: 403,
    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: 'Fri, 17 Nov 2023 11:39:18 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': 'public_repo, 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': 'D1EE:85F2:3BE93E30:3CA3C8E4:655750E6',
      'x-oauth-scopes': 'repo',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4992',
      'x-ratelimit-reset': '1700224200',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '8',
      'x-xss-protection': '0'
    },
    data: {
      message: 'You need admin access to the organization before adding a repository to it.',
      documentation_url: 'https://docs.github.com/rest/repos/repos#create-an-organization-repository'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/orgs/REMOVED/repos',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/20.0.2 octokit-core.js/5.0.1 Node.js/20.7.0 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"name":"joe-test-123","description":"test","visibility":"private"}',
    request: { hook: [Function: bound bound register] }
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@devjoes devjoes added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Nov 17, 2023
Copy link
Contributor

👋 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! 🚀

@kfcampbell kfcampbell moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Nov 20, 2023
@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Nov 20, 2023
@kfcampbell
Copy link
Member

@wolfy1339
Copy link
Member

Unfortunately those plugins don't adapt type for common endpoints between github.com, GHES and GHEC.

@devjoes Is this for an enterprise version of github, or the standard github.com?

@gr2m
Copy link
Contributor

gr2m commented Nov 27, 2023

@kfcampbell @wolfy1339 the ergonomics of GHES / GHEC endpoints are much better implemented in https://github.com/octokit/octokit.js, see this update octokit/octokit.js#2127 (comment). It's hard to make types work well for targets other than dotcom with the way types are implemented for current Octokit.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

4 participants