Upgrading from `@actions/github` V5 -> V6 caused TypeErrors within `getOcktokit()`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Wasn't entirely sure if this issue belonged here or plugin-rest-endpoint-methods.js as the error was emitting from plugin-rest-endpoint-methods.js: https://github.com/octokit/plugin-rest-endpoint-methods.js/issues/683.
What happened?
Version 5 of @actions/github, I was able to do this within my tests:
import { getOctokit } from '@actions/github'
import type { Endpoints } from '@octokit/types'
import sinon from 'sinon'
const octokit = getOctokit('token')
const stubLabelList = () => {
return sinon.stub(octokit.rest.issues, 'listLabelsForRepo').resolves({
data: [MOCK_LIST_LABELS],
status: 200
} as Endpoints["GET /repos/{owner}/{repo}/labels"]["response"])
}
}
const github = {
getOctokit: () => octokit
}
// pass github to other test functions etc
As of version 6, I've had to do something like:
import { getOctokit } from '@actions/github'
import type { Endpoints } from '@octokit/types'
import sinon from 'sinon'
const octokit = getOctokit('token')
const github = {
getOctokit: () => {
...octokit,
rest: {
issues: {
listLabelsForRepo: () => {
return {
data: [MOCK_LIST_LABELS],
status: 200
} as Endpoints["GET /repos/{owner}/{repo}/labels"]["response"])
}
}
}
}
}
I noticed this was a change in way the endpoints are generated and is now done via a proxy as of https://github.com/octokit/plugin-rest-endpoint-methods.js/pull/622, could this of introduced unwanted side effects or is this the intended behaviour?
Versions
@actions/github: v6
NodeJS: 18
Relevant log output
TypeError: Cannot destructure property ‘decorations’ of ‘endpointMethodsMap.get(...).get(...)’ as it is undefined.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at getOctokit in @actions/github and the proxy-based endpoint generation in plugin-rest-endpoint-methods.js, then compare the v5 and v6 behavior with plugin pull request 622 and issue 683. Reproduce the TypeError while stubbing listLabelsForRepo; done means determining whether the proxy causes the regression and resolving or documenting the changed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100