actions/github-script "HttpError: Not Found" from the wrong repo context
github-script throws "HttpError: Not Found" when the REST call resolves to a repo, owner, or resource the token can see but that does not contain the thing you asked for. The credentials are valid; the address is wrong.
What this error means
A github-script step fails with "Error: HttpError: Not Found" even though the token has access to the workflow repo.
RequestError [HttpError]: Not Found
at /home/runner/work/_actions/actions/github-script/v7/dist/index.js
status: 404
##[error]Unhandled error: HttpError: Not FoundCommon causes
Hardcoded owner/repo that differs from context
The script passes a literal owner or repo that does not match where the resource lives, so the API resolves a 404.
Resource id from a different repository
An issue, PR, or run number from another repo is queried against context.repo, which does not contain it.
Reusing context.repo in a cross-repo call
context.repo always points at the workflow repo; cross-repo calls must set owner and repo explicitly.
How to fix it
Pass owner and repo from context explicitly
- Destructure owner and repo from context.repo for same-repo calls.
- For cross-repo calls, set owner and repo to the target repository literally.
- Re-run and confirm the resource resolves.
- uses: actions/github-script@v7
with:
script: |
const { data } = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
core.info(data.title);How to prevent it
- Never hardcode owner/repo when context.repo will do.
- Log owner/repo/number before the call so a 404 points at the address, not the auth.