koala73/worldmonitor · error · Error
a pull_request payload is required
Error message
a pull_request payload is required
What it means
checkClosedPull validates that the GitHub webhook event object passed in actually contains a pull_request payload before analyzing a merged/closed PR stack. The library throws this when event exists (or is undefined) but event.pull_request is missing, because every downstream step (repository resolution, queue traversal, verdict computation) depends on PR fields like number and merge info. It is an upfront contract check on the caller-supplied event.
Solutions
- Trigger the workflow on pull_request (or pass a pull_request webhook payload) so event.pull_request is populated.
- If loading event JSON manually, point at the correct github.event_path file containing a pull_request payload.
- Guard the call: only invoke checkClosedPull when event?.pull_request is truthy, or skip with a clear log for non-PR events.
Example fix
// before
checkClosedPull({ event: github.event, gh, git, issues, sleep });
// after
if (github.event?.pull_request) {
checkClosedPull({ event: github.event, gh, git, issues, sleep });
} Defensive patterns
Strategy: validation
Validate before calling
if (!event?.pull_request) { console.warn('not a pull_request event; skipping'); return; }
checkClosedPull({ event, gh, git, issues, sleep }); Type guard
function isPullRequestEvent(event) {
return typeof event === 'object' && event !== null && typeof event.pull_request === 'object' && event.pull_request !== null;
} Try / catch
try {
checkClosedPull({ event, gh, git, issues, sleep });
} catch (e) {
if (e.message === 'a pull_request payload is required') return skipNonPrEvent();
throw e;
} Prevention
- Restrict the workflow trigger to pull_request events (on: pull_request).
- Assert the event shape in a smoke test before invoking library helpers.
- Log event.action/event_name when debugging wrong-payload wiring.
When it happens
Trigger: Calling checkClosedPull({ event }) where event is a non-pull_request GitHub event (e.g. push, issues), where event is an empty object {}, or where event is undefined/null and the default {} destructure applies.
Common situations: Wiring the handler to the wrong GitHub Actions event name (e.g. 'push' instead of 'pull_request'), reading the event JSON from a path that contains a different payload, or a workflow_dispatch invocation where no pull_request context exists.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- ${label} HTTP 400
- Could not resolve ${JSON.stringify(echoCountryInput(raw))} t
- INCOMPATIBLE_DELIVERY
- COUNTRIES_LIMIT_EXCEEDED
- TICKERS_LIMIT_EXCEEDED
AI-assisted analysis of koala73/worldmonitor@7d06c8633d (2026-09-15).
Data as JSON: /api/errors/34746ed10a965f7b.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/check-stacked-merge.mjs:365
if (pull.number != null) {
issueClient.comment(pull.number, formatOrphanComment({
pull, mergeSha, defaultBranch, parents, reason: verdict.reason,
}));
}
}
}
return {
...verdict,
parents,
existingIssue,
exitCode: verdict.ok ? 0 : 1,
...(!verdict.ok && { annotation: postMergeAnnotation(verdict, mergeSha, defaultBranch) }),
};
}
export function checkClosedPull({ event, gh, git, issues, sleep } = {}) {
if (!event?.pull_request) throw new Error('a pull_request payload is required');
const repository = repositoryFromEvent(event);
const queue = [event.pull_request];
const visited = new Set();
const results = [];
for (const pull of queue) {
if (visited.has(pull.number)) continue;
visited.add(pull.number);
const result = checkStackedMerge({
mode: 'post-merge', event: { ...event, pull_request: pull }, gh, git, issues, sleep,
});
results.push({ pullNumber: pull.number, ...result });
if (!pull.head?.ref || pull.head.repo?.full_name !== repository) continue;
const children = flattenGhPages(gh([
'api', '--paginate', '--slurp',
`repos/${repository}/pulls?state=closed&base=${encodeURIComponent(pull.head.ref)}`,
]));
queue.push(...children.filter((child) => isMergedPull(child)
&& (!child.base?.repo?.full_name || child.base.repo.full_name === repository)));View on GitHub (pinned to 7d06c8633d)