Skip to content

[BUG]: Upgrading from @actions/github V5 -> V6 caused TypeErrors within getOcktokit()  #683

@Zidious

Description

@Zidious

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  and stubLabelList 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 #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.

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: BugSomething isn't working as documentedreleased

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions