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]: Error when using retry plugin with codeowners errors request #536

Open
1 task done
trv-nmontele opened this issue Apr 5, 2024 · 1 comment
Open
1 task done
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@trv-nmontele
Copy link

What happened?

the @octokit/plugin-retry package is unable to handle calling the Github API endpoint to list CODEOWNERS errors (https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-codeowners-errors).

Since the API endpoint by default is expected to return a list of errors, in the case where there are no errors it will return an empty list. However, the retry plugin specifically checks to see if the errors list exists in the response:

response.data.errors &&

The retry plugin will then try to log the first error message. This will throw an error if the list is empty.

Here is the code I am using

import {Octokit} from "@octokit/core";
import {retry} from "@octokit/plugin-retry";

const MyOctokit = Octokit.plugin(retry)
const client = new MyOctokit({
    auth: token,
    baseUrl: url,
});

const getCodeownerIssues = async (owner, repo) => {
    return await client.request("GET /repos/{owner}/{repo}/codeowners/errors", {
        owner,
        repo,
    });
}

When I run this code I get an error message from the octokit/plugin-retry, however when I remove the retry plugin, I get a success response.

See the Relevant log output section for the error message I am getting.

Versions

Node v18.16.0, @octokit/core v6.1.1, @octokit/plugin-retry v7.1.0

Relevant log output

file:///C:/Project%20Area/test-octokit/node_modules/@octokit/plugin-retry/dist-bundle/index.js:38
    response.data.errors[0].message
                            ^

TypeError: Cannot read properties of undefined (reading 'message')
    at requestWithGraphqlErrorHandling (file:///C:/Project%20Area/test-octokit/node_modules/@octokit/plugin-retry/dist-bundle/index.js:38:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Job.doExecute (C:\Project Area\test-octokit\node_modules\bottleneck\light.js:405:18)

Node.js v18.16.0

Code of Conduct

  • I agree to follow this project's Code of Conduct
@trv-nmontele trv-nmontele added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Apr 5, 2024
Copy link

github-actions bot commented Apr 5, 2024

👋 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 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 Apr 15, 2024
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

2 participants