auth-app.js: Throw a descriptive error when permissions is not set

Hello,

I ran into an issue where when I did not set a permissions object, even an empty one, in the the auth options I would see the following error:

Cannot convert undefined or null to object

Upon debugging it seems as if it comes from here:

https://github.com/octokit/auth-app.js/blob/0b50bb41fb850bb3398f0449bd3a4438ff04acff/src/cache.ts#L72

If no permissions are passed in, the Object.keys throws the Cannot convert undefined or null object.

It was not clear from the documentation that the permissions object is required. Examples in the documentation seem to leave that out.

Small Reproducer

const auth = createAppAuth({
  id: 123,
  privateKey: `-----BEGIN RSA PRIVATE KEY-----...`,
  installationId: 456,
});

const installationAuthentication = await auth({
  type: 'installation',
  // permissions: {}, // This is what I added to make it work
});

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (7 by maintainers)

Commits related to this issue

Most upvoted comments

FWIW, I am also on Enterprise 2.18 and had to add the empty permissions object in order to get the request to work successfully.

From my testing, the permissions are all the permissions inherited from the installation.

I’d phrase it as

<strong>Required for GitHub Enterprise Server 2.18 and below. Specify an empty object `{}` for all permissions granted by the installation.</strong>

@gr2m My enterprise version is now 2.20.0 and I can generate a token without the empty permissions object now.

Can anyone check if the problem persists in 2.19?

We are upgrading at the end of this month, so I can try again at the start of March and let you know.