Skip to content

feat: use pulls API when issue processing is fully disabled#1334

Open
roramirez wants to merge 1 commit intoactions:mainfrom
roramirez:feat/use-pulls-api-when-issues-disabled
Open

feat: use pulls API when issue processing is fully disabled#1334
roramirez wants to merge 1 commit intoactions:mainfrom
roramirez:feat/use-pulls-api-when-issues-disabled

Conversation

@roramirez
Copy link
Copy Markdown

Description

When both days-before-issue-stale and days-before-issue-close are set to -1, getIssues now calls pulls.list instead of issues.listForRepo. This avoids the need for any issues permission in the workflow, since the GitHub issues API is never called.

Before this change, even with issue processing fully disabled via -1, the action would still call issues.listForRepo on every run — which requires issues: read or issues: write. This caused failures in setups where the GitHub App or token does not have issues permission (e.g. repositories with issues disabled, or App tokens scoped only to pull requests).

Changes:

  • src/classes/issues-processor.ts: getIssues checks if issues are fully disabled (daysBeforeIssueStale < 0 && daysBeforeIssueClose < 0) and uses pulls.list in that case
  • Sort field comments is mapped to created for the pulls API, which does not support comments sorting
  • Items returned via pulls.list are mapped with pull_request: {} so they are correctly identified as pull requests downstream
  • __tests__/get-issues-api-selection.spec.ts: 8 tests covering all branching conditions (both -1, only one -1, NaN fallback, PR mapping, sort field mapping)
  • README.md: documents the permission optimization in the "Recommended permissions" section and in the days-before-issue-stale / days-before-issue-close option descriptions

Related issue

Fixes #1307

Check list

  • Documentation changes added (README updated with permission optimization notes)
  • Tests added to cover all branching conditions and PR mapping

@roramirez roramirez requested a review from a team as a code owner April 30, 2026 23:22
When both days-before-issue-stale and days-before-issue-close are set
to -1, getIssues now calls pulls.list instead of issues.listForRepo.
This avoids the need for any issues permission in the workflow, since
the GitHub issues API is never called.

- Sort field 'comments' is mapped to 'created' for the pulls API
  (which does not support comments sorting)
- Items returned via pulls.list are mapped with pull_request: {}
  so they are correctly identified as pull requests downstream
- Adds tests covering all branching conditions and the PR mapping
- Documents the permission optimization in README
@roramirez roramirez force-pushed the feat/use-pulls-api-when-issues-disabled branch from 14ecec0 to 60f05ae Compare April 30, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: Getting issues was blocked by the error: Resource not accessible by integration

1 participant