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]: octokit.rest.search.issuesAndPullRequests() reports that it is deprecated but no alternative seems to be provided #2832

Closed
1 task done
mcdurdin opened this issue Mar 20, 2025 · 5 comments
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented

Comments

@mcdurdin
Copy link

What happened?

Calling octokit.rest.search.issuesAndPullRequests() results in a warning:

octokit.rest.search.issuesAndPullRequests() is deprecated, see https://docs.github.com/rest/search/search#search-issues-and-pull-requests

e.g.

const issues = await octokit.rest.search.issuesAndPullRequests({
  q: `is:issue AND is:open AND label:bug`,
  per_page: 5,
});

Opening the referenced link mentions that use of the endpoint without the advanced_search=true parameter is deprecated. However, adding that parameter does not suppress the warning (and the endpoint remains crossed out in VS Code):

const issues = await octokit.rest.search.issuesAndPullRequests({
  q: `is:issue AND is:open AND label:bug`,
  advanced_search: true,
  per_page: 5,
});

Is there an alternate endpoint we should be using, or is this a bug in the deprecation of the issuesAndPullRequests endpoint?

Versions

Octokit 4.1.2 (via NPM)

Relevant log output

Code of Conduct

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

👋 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 labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

wolfy1339 commented Mar 20, 2025

Duplicate of #2828

Unfortunately, the deprecation is set for the whole endpoint. There isn't a way to silence it when using the advanced_search parameter.
You will have to simply ignore the TypeScript warnings.

https://github.blog/changelog/2025-03-06-github-issues-projects-api-support-for-issues-advanced-search-and-more/

The deprecation warning is a bit misleading, as the endpoint is getting a change in functionality after the deprecation date. The advanced_search parameter will get removed at that time

See also octokit/request.js#746

@github-project-automation github-project-automation bot moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Active Mar 20, 2025
@mcdurdin
Copy link
Author

Thank you for quick response. The title of the other issue certainly misled me when I was searching for existing reports!

The difficulty is the deprecation warning continues to be printed to the console, even with advanced_search, and there does not appear to be any option to turn that off. I have temporarily monkeypatched octokit to suppress the warnings:

const oldWarn = octokit.log.warn;
octokit.log.warn = (...args) => args.some(arg => arg.includes('octokit.rest.search.issuesAndPullRequests') && arg.includes('deprecated')) ? null : oldWarn.apply(octokit.log, args);

@wolfy1339
Copy link
Member

wolfy1339 commented Mar 20, 2025

It only prints the deprecation warning when it receives it from GitHub.

Which makes me believe that the advanced_search parameter isn't getting sent, which is odd.

Other people have reported success using that parameter

@mcdurdin
Copy link
Author

My reading of endpoints-to-methods.ts:withDecorations() is that the warning is always printed, before the request is sent. In endpoints-to-methods.ts:149-151:

    if (decorations.deprecated) {
      octokit.log.warn(decorations.deprecated);
    }

And when I turn on request logging, I see advanced_search is passed to GitHub:

octokit.rest.search.issuesAndPullRequests() is deprecated, see https://docs.github.com/rest/search/search#search-issues-and-pull-requests
request {
  method: 'GET',
  baseUrl: 'https://api.github.com',
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'octokit.js/0.0.0-development octokit-core.js/6.1.4 Node.js/20.16.0 (win32; x64)'
  },
  mediaType: { format: '', previews: [] },
  request: { hook: [Function: bound bound register] },
  url: '/search/issues',
  q: 'is:issue AND is:open AND label:bug',
  advanced_search: true,
  per_page: 5
}
GET /search/issues?q=is%3Aissue%20AND%20is%3Aopen%20AND%20label%3Abug&advanced_search=true&per_page=5 - 200 with id DA64:33070C:1A89845:351E8E0:67DC9BE1 in 1828ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

2 participants