Skip to content

fix: Guard nil Request in ParseRequestPayload - #4759

Open
asxxb wants to merge 1 commit into
google:masterfrom
asxxb:fix/hook-delivery-parse-nil-request
Open

asxxb wants to merge 1 commit into
google:masterfrom
asxxb:fix/hook-delivery-parse-nil-request

Conversation

@asxxb

@asxxb asxxb commented Dec 4, 2026

Copy link
Copy Markdown

Fixes #4758

Problem

(*HookDelivery).ParseRequestPayload() panics with a nil pointer dereference when d or d.Request is nil (for example, on HookDelivery items returned by ListHookDeliveries, where Request is not populated).

Root Cause

ParseRequestPayload() accessed d.Request.RawPayload directly without checking whether d or d.Request was nil.

Solution

Return an error ("hook delivery request is nil") when d == nil || d.Request == nil before accessing d.Request.RawPayload.

Testing

Added TestHookDelivery_ParseRequestPayload_nilRequest in github/repos_hooks_deliveries_test.go covering both a nil *HookDelivery receiver and a HookDelivery with Request == nil. Ran script/fmt.sh, script/test.sh, and script/lint.sh across all module directories.

Note: An AI coding assistant helped identify the bug, write the fix and regression test, and draft this description; all changes were reviewed and tested locally.

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.

HookDelivery.ParseRequestPayload panics when Request is nil

1 participant