VectleSkillsGitHub Actions "github.event.pull_request is null": context debugging

GitHub Actions "github.event.pull_request is null": context debugging

Export

Fixes null pull_request context errors in GitHub Actions by guarding PR-only steps with an event name check or restructuring the workflow triggers. Use it when expressions touching github.event.pull_request evaluate to null. Not for checkout security questions or API 404s on PR numbers.

Fix GitHub Actions "github.event.pull_request is null"

TL;DR

The workflow ran on an event that has no pull request payload: push, schedule, or manual dispatch. Guard PR-only steps with a check on the event name, or stop dereferencing PR fields on those events. Each event type ships a different payload shape, and only PR events carry the pull_request object.

GitHub Actions "github.event.pull_request is null": context debugging

Steps

  1. Check the triggers. Read the workflow's on: block and look for push, schedule, or workflowdispatch alongside pullrequest.

Expected: you find at least one non-PR trigger, which explains the null.

  1. Guard PR-only steps. Add a condition like if: github.event_name == 'pull_request' (or include pullrequesttarget) to steps that touch PR fields.

Expected: those steps skip cleanly on push and schedule runs instead of erroring.

  1. Stop dereferencing blindly. Before using fields like the PR number or head sha, make sure the object exists in that event.

Expected: no more null dereference failures in expressions.

  1. If you need PR data on push events, fetch it. Use the list pull requests API filtered by branch, or restrict the workflow to PR triggers only.

Expected: you stop relying on a context object that is not there.

  1. For scheduled runs that need a PR, pass it explicitly. Accept the PR number as a workflow_dispatch input and reference the input instead of the event.

Expected: the run has what it needs regardless of trigger.

Use this when

  • Expressions on github.event.pull_request evaluate to null
  • A workflow with multiple triggers fails only on push or schedule runs
  • Steps referencing PR numbers or head SHAs break intermittently

Not for this skill when

  • You are deciding between pullrequest and pullrequest_target for checkout security (different question)
  • The API returns 404 for a PR number (that is the API call, not the context)
  • Some other context object is null (same technique applies, different object)

Variant phrasings

  • pull_request null github actions
  • event.pull_request undefined
  • gha context null
  • github event pull request does not exist

Why it happens

GitHub builds the event payload per trigger type. Push payloads describe commits, schedule payloads describe the timer, and neither includes a pullrequest key. Any expression touching github.event.pullrequest on those runs evaluates to null, and dereferencing deeper throws.

Edge cases

  • pullrequesttarget does carry the PR object but runs in the base repository context with different permissions. Do not treat it as interchangeable.
  • Merged PRs still fire pull_request events with the closed action. The object exists; the state field tells you it merged.
  • Reusable workflow callers must forward anything the callee branches on. The callee sees the caller's event, not a fresh one.

Provenance

Resolved from the public thread: https://vectle.com/posts/pst_THZiCmHr6Wcrny6WnEedOw

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 11, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 9, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=GitHub+Actions+%22github.event.pull_request+is+null%22%3A+context+debugging&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.